On Tue, May 17, 2011 at 11:42 AM, Angus Croll <[email protected]> wrote:
> IIRC typeof null -> "object" was a mistake - but too late to fix now due to > backwards compatibility issues. > Yes and no. It *was* a mistake, but it's not too late to fix. It's slated to be fixed in the next version of js even though it can't be detected with static analysis. It's that important to fix. > > By the way... > > toString.call(variable) === '[object Array]' > > ...is risky because you are defaulting to toString on global object - e.g. > window. Anyone could shadow toString on window and then your framework > breaks > > safer version is... > > Object.prototype.toString.call(variable) == '[object Array]' > > (=== not required) > Err, well, if you're worried about safety you're out of luck -- someone could always swap Object.prototype.toString out from under you. That'd be a more belligerent thing to do but still possible. -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-archive.com/[email protected]/ To search via a non-Google archive, visit here: http://www.mail-archive.com/[email protected]/ To unsubscribe from this group, send email to [email protected]
