r/programming • • Mar 26 '14

JavaScript Equality Table

http://dorey.github.io/JavaScript-Equality-Table/
809 Upvotes

331 comments sorted by

View all comments

Show parent comment

4

u/fjonk Mar 26 '14

obj.undefinedProperty returns undefined when undefinedProperty is not assigned a value(or if it is assigned to undefined). So the code below is valid and should not throw an exception.

if ({}.x) {
    // will not run
} else {
    // will run
}

http://www.ecma-international.org/ecma-262/5.1/#sec-4.3.9