반응형

아래와 같이 jsonVal이라는 데이터가 있다고 가정하고

jsonVal = [

    {name:'사과',price:100},

    {name:'자두',price:50},

    {name:'포도',price:200},

]

jsonVal에서 '사과'의 price를 찾고 싶을경우 아래와 같이 사용할 수 있다.

 

jsonVal.filter(

    function(e){

        return e.name == '사과'

    }

)[0].price

 

※참고 : https://emessell.tistory.com/184

+ Recent posts