Skip to main content
6 events
when toggle format what by license comment
May 11, 2015 at 22:29 history edited Thriggle CC BY-SA 3.0
fixed a typo
May 11, 2015 at 22:15 comment added Thriggle Yeah, directly comparing the constructors would work too, is certainly faster, and is definitely better from a readability perspective. The only reason to be wary of that approach is that it can fail if an object has a property defined with the key constructor e.g. var obj = {name:"bob",constructor:"the builder"}
May 11, 2015 at 21:46 comment added bpbutti Also, I had never heard of Object.prototype.toString.call(obj).slice(8, -1), but wouldn't it be better to just use (object.constructor === something) ?
May 11, 2015 at 21:44 comment added bpbutti Thanks for the feedback! The way you explained about the base numbers conversion really helped me understand it. In the code, though, parseInt is only run when the input is a string, so parseInt('036', 10) works. But I got your point, and now I understand why toString doesn't work.
May 11, 2015 at 19:39 history edited Thriggle CC BY-SA 3.0
added 789 characters in body
May 11, 2015 at 15:57 history answered Thriggle CC BY-SA 3.0