I have to put a validity check before performing any operation using the object which -
- If that object exists.
- If its exists then a certain property also exists on it.
For ex-
var obj = {
key: "value"
}
Now the most conventional way to do this is-
if(obj) {
if(obj.hasOwnProperty('key') {
//Do some action (validity check pass)
//For Example- console.log(obj.key);
}
}
But i am looking for a more faster and efficient way there must be to solve this.