Am not new to JS or its syntax, but sometimes, the semantics of the language has me stumped at times. At work today, a colleague mentioned this: is not the same as or since the first version actually assigns the reference to an empty array to a and b. I couldn’t quite accept this as true, but I’m not sure.
How can I determine whether an object x has a defined property y, regardless of the value of x.y? I’m currently using but that seems a bit clunky. Is there a better way? Answer Object has property: If you are testing for properties that are on the object itself (not a part of its prototype chain) you can use .hasOwnProperty():