JavaScript - Property exists 'in' the object

preview_player
Показать описание
Check if a property (or attribute) exists in an object. Does the object "fruit" have property called "color"?

let fruit = { "color":"red", "flavor":"sweet", "shape":"round"}

if ("color" in fruit)
display(true);
else
display(false);
Рекомендации по теме