Filter array of objects by object key

后端 未结 3 437
甜味超标
甜味超标 2021-01-07 05:46

I have an array of objects in Javascript:

var List = [
            {
                employee:\'Joe\',
                type:\'holiday\',
            },
              


        
3条回答
  •  旧时难觅i
    2021-01-07 05:53

    Sorry - I don't have the rep. to comment yet but I believe it should be

    return el.employee === ename;  // No quotes around ename
    

    Otherwise the answer @Ben gives is perfect - it can be extended into a 'groupby' function if using underscore is out of the question a the project.

提交回复
热议问题