简体   繁体   中英

Check if the value of an object property is an object

 const opb = { 'e' : 1, '3' : 2, '4' : {'ee':12} } Object.entries(opb).forEach(el => {console.log(el[1] !== typeof 'object' , typeof el[1])})

Hello im building a check that checks if the first value of an object property is another object.

I am doing this as follow:

 const opb = { 'e' : 1, '3' : 2, '4' : {'ee':12} } Object.entries(opb).forEach(el => {console.log(el[1] !== typeof 'object' , el[1])})

Somehow everything returns true, eventho one should be an object (false).

It should be typeof el[1] !== 'object' .

 const opb = { 'e' : 1, '3' : 2, '4' : {'ee':12} } Object.entries(opb).forEach(el => {console.log(typeof el[1] !== 'object' , el[1])})

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM