assign value to object property if object exists javascript code example
Example 1: check if js property exists in class
myObj.hasOwnProperty(myProp)
Example 2: check if field exists in object javascript
if ('field' in obj) {
}
myObj.hasOwnProperty(myProp)
if ('field' in obj) {
}