javascript - finding a value in an object -


i have object:

{    id: 16,     defs: {       name: "depot (float)", field: "depot"    } } 

and array (which can have more 1 object in purposes of has one):

[   {     percentage monthly potential: 1,      area manager: "ashar",      business unit: "retail",      cust no: 68345,      depot name: "leicester",      group number: "",      depot: 14,      target: 46100   } ] 

what need take field value object , use find key matches in second object , retrieve value of it, in case should getting 14.

any appreciated.

thanks time.

if using es6, can try this:

const field = lookupobject.defs.field;  const matches = array.map(arrayitem => {     return {         field,         value: arrayitem[field]     } }); 

the matches array contain data interested in.


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -