Better HN
topnewbestaskshowjobs
Log inSign up

nachoplatter

2 karma · joined Oct 29, 2013 (13y ago) · 1 submissions

Submissions

comment 13y ago · link · parent

"The built-in option to check an object’s ‘type’ is instanceof, which looks at the function an object was created with."

Nitpick, because I happen to be teaching myself the Javascript class system right now: instanceof examines an object's prototype inheritance, not its constructor. x instanceof Y if x inherits from Y.prototype, so it's possible to "sever" an object from its constructor by replacing the constructor's prototype property. Coming from a strongly typed language, this takes some getting used to!