9 ms·
Yes, new.target was cited as a precedent for this decision. Even though new.target itself was such an ugly hack that the spec was specifically coded for new.tar
by dmitriid 4y ago
Yes, new.target was cited as a precedent for this decision. Even though new.target itself was such an ugly hack that the spec was specifically coded for new.target alone.
So import is:
- a keyword that can only exist at top level at the top of the file
- except when it looks like a function, but it's not a function and doesn't behave like one
- and it's also apparently and object because it has what looks like a property on it
IIRC there was a proposal for an Import (or was it System?) that would take care of things like import.meta etc., but it was deemed to complex. Instead we have import()
- WorldMaker 4y ago> and it's also apparently and object because it has what looks like a property on it In JS functions are objects, so this isn't that weird for JS. (For easy example, JQuery alone used this a lot with `$('selector')` and `$.ajax(…)` and all sorts of other things.)
- dmitriid 4y agoYes, but import() isn't a function ;)