Monday, 1 July 2019

React Native/Javascript - How to know that object does not have the property?

Let say :



myVariable.color;
myVariable.height;

myVariable.width;


But sometimes, myVariable only have "color" and "height" property.



I have try this, but no luck :



if(myVariable.width == undefined) {
//but not filtered here
}



How to know if myVariable doesn't contain "width" property by code, is it possible ?

No comments:

Post a Comment