7

hey node what type is this?

> typeof []
'object'

but then

> Object.defineProperties.call([])
Uncaught TypeError: Object.defineProperties called on non-object

so is [] an object or not?

Comments
  • 1
    Quick question, does it behave the same way with new Array instead of []?
  • 1
  • 2
    Yes, there's a thin object hierarchy in js, the only members that aren't part of it are the "primitives"
  • 2
    Its an old legacy js problem that, if fixed now would break massive amount of code.
  • 1
    @Voxera isn't the point of major version bumps breaking changes?
  • 2
    @vorticalbox not if you break literally millions of pages like banking and such.

    And remember, you have to convince not only node.js but browsers to to get any traction.

    Good luck getting MS, Apple and Google to break thing just to please us coders ;)
  • 2
    @Voxera I mean, JS could include version/dialect options, set in <head>
  • 1
    @Lor-inc
    This. I've been floating the idea for years as part of a bigger transparent capabilities feature. The big resistance to it comes from the browser implementors. They'd end up having to support different discrete selectable runtimes simultaneously in order for it to be meaningful, which means multiple incompatible versions of the engine running at the same time.

    The Js ecosystem is kind of nightmarish when you peel back the veneer a little.
  • 0
    @Lor-inc @SortOfTested no. What is <head>? the html tag? Wtf?

    What we need are interpreter pragmas. A bit like "use strict";. So it can be used in Browsers and NodeJS.
  • 1
    @nitwhiz
    Less head, more runtine bootstrap configuration. I'm open to whatever impl makes sense. Browsers could expose a hook in head, node arg at init, etc etc.
  • 0
    @SortOfTested That doesn't make sense imo. The code only works if the specified settings for the engine are set (like arrayBullshitForNoobs=true), so it makes no sense to set this thing as far from your code away as possible. As we have no compiler, it has to go into the file.
  • 1
    @nitwhiz
    It could also go on the reference. It actually makes sense to create a configuration decouple for that based on targets. Then there's the regression story.

    Either way, Osmani and the rest of the gang have already hard vetoed it, so it's a bit of a moot point.
  • 0
    Isn't the first argument of Function.prototype.call `this`? And the second argument is the first argument passed to the function.
Add Comment