You can permanently fix any such type-checks by `function isObject(x) { return x && (typeof x === 'object' || typeof x === 'function'); }`, or `function isObject(x) { return x && Object(x) === x; }`, etc.
On Tue, Jul 17, 2018 at 7:05 PM, Kai Zhu <kaizhu...@yahoo.com> wrote: > >You already can't use `new` with `Symbol`, and you don't ever want to use > `new` with a primitive's constructor anyways. > > this would be *okay* if we limit the number of primitive-types in the > language to a small-number (maybe add BigDecimal, but that's it), so its > easy to remember. i'm concerned that we have one too many needless > primitives already (Symbol should've been an object, and it not requiring > 'new' looks more like a wart to me). > > adding more primitives at this point, will only make this pedantic-rule > look more like a wart, and trip-up beginners (and their prejudice on the > language's inconsistencies). it also complicates integration-work on > web-projects, due to difficulty baton-passing new primitives around via > JSON, and having to continually refactor type-checks that rely on typeof. >
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss