> On Oct 14, 2016, at 11:02 AM, Claude Pache wrote:
>
>
>> Le 11 oct. 2016 à 11:07, medikoo a écrit :
>>
>> I was searching the archived but wasn't able to find the answer.
>>
>> What's the reasoning behind having Number(symbol) crash
I haven't seen this discussed on ESDiscuss before. For those not
familiar with user-defined literals: Essentially, they allow certain
literals (e.g. 123.45, "hello") to produce a user-defined object by
marking the literal with a user-defined suffix.
They were introduced in C++11 [1], and I'm
> Le 11 oct. 2016 à 11:07, medikoo a écrit :
>
> I was searching the archived but wasn't able to find the answer.
>
> What's the reasoning behind having Number(symbol) crash instead of returning
> NaN (as it's in case all other non-coercible values?). It feels
Just one thought:
> Of course, in the top-level invocation it might be a good idea to use a
`catch`
after years of engine developers advocating "avoid try/catch as much as
possible because it de-opts and slow down code and JIT and you name it",
above suggestion doesn't really look like an "of
To perhaps clarify this point a bit, it is very important to `.catch()` and
react appropriately at the ends of promise chains. If synchronous code fails
for an unexpected reason, a visible crash will definitely happen. This is not
the case for promises, because there’s no way for the runtime to
> Le 14 oct. 2016 à 16:52, Rick Waldron a écrit :
>
> Python is also inconsistent:
>
> >>> pow(-2, 2)
> 4
> >>> -2 ** 2
> -4
> >>>
This is not inconsistency, but that follows from operator precedence rules
(those used in mathematics, not in C).
In the same vein, you
Here's some more specific notes:
On Fri, Oct 14, 2016 at 7:31 AM Cyril Auburtin
wrote:
> I would expect `-2**3` to return -8, or `-2**2 == -4`, since it should be
> like `-(2**3)`
>
Math.pow(-2, 3) === -8
Math.pow(-2, 2) === 4
To get -4: -Math.pow(-2, 2)
> Firefox
On Fri, Oct 14, 2016 at 7:31 AM Cyril Auburtin
wrote:
> I would expect `-2**3` to return -8, or `-2**2 == -4`, since it should be
> like `-(2**3)`
>
This was discussed extensively during the design process and determined
that requiring user code to be explicit about
On Fri, Oct 14, 2016 at 9:05 AM Brian Ninni wrote:
> I did a quick search and didn't find any recent mentions of this topic.
>
> On more than one occasion I've had to determine whether something was a
> plain old Object, or some other class. This involves checking that the
Object literals (object initializers) are just a convenient way to create a new
ordinary object which (initially) inherits from `Object.prototype`, and
populate it with some properties.
I don't think you should be able to distinguish them from similar objects not
created using object
>
> `({}).toString.call(o);`
This does work for all Native class, but still returns "[object Object] "
for user created classes
`Object.getPrototypeOf({}) === Object.prototype // true`
Did not know of that method. Seems like a roundabout way, but it works.
I wrote:
Brian Ninni wrote:
On more than one occasion I've had to determine whether something was a
plain old Object, or some other class. This involves checking that the
given object was NOT an instanceof any other acceptable class.
`Object.prototype.isPrototypeOf(o)` should do that (if you
Jordan Rome schrieb:
My apologies if this has already been discussed but what is the "preferred"
pattern for using await ? Since await, which runs on promises, will now
throw if the promise is rejected (preventing execution of code after the
await and killing the process in Node), is it
Brian Ninni wrote:
On more than one occasion I've had to determine whether something was a
plain old Object, or some other class. This involves checking that the
given object was NOT an instanceof any other acceptable class.
`Object.prototype.isPrototypeOf(o)` should do that (if you don't
If you want to check that your variable is a plain old object and not some
other class, you can use
`Object.getPrototypeOf(x) === Object.prototype`
`Object.getPrototypeOf({}) === Object.prototype // true`
`Object.getPrototypeOf(new Map()) === Object.prototype // false`
Le ven. 14 oct. 2016 à
2016-10-14 15:05 GMT+02:00 Brian Ninni :
> I did a quick search and didn't find any recent mentions of this topic.
>
> On more than one occasion I've had to determine whether something was a
> plain old Object, or some other class. This involves checking that the
> given
I did a quick search and didn't find any recent mentions of this topic.
On more than one occasion I've had to determine whether something was a
plain old Object, or some other class. This involves checking that the
given object was NOT an instanceof any other acceptable class.
Array, RegExp,
I was testing something https://caub.github.io/misc/calculator, and I
didn't see how it would be a problem to have the precedence of ** higher
than unaries.
But at least I'm happy something like (2).pow(3) wasn't chosen.
Thanks anyway and sorry for discussing something already frozen in spec
Ah, ok, a bit sad because all more scientific languages, and python too,
all math books, all will use `-e^3` for meaning `-(e^3)` (^ or **), because
it's just `-exp(3)` or `-pow(E, 3)`
and `(-1)^n` otherwise, when we want to take the signs with.
If you wanted to avoid any confusion you could
Cyril Auburtin schrieb:
I would expect `-2**3` to return -8, or `-2**2 == -4`, since it should be
like `-(2**3)`
You would, others would not. -2 ** 2 clearly should return 4, shouldn't it?
Is there a reason for this restriction? Python does it `-2**3` fine
Because of the ambiguity it has
What does it change if it handles floats?
I just checked
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence
unary + is 16, while exponentiation is 15, so the opposite order that I
thought
2016-10-14 13:37 GMT+02:00 J Decker :
>
probably because it's floating point native not integer like you'd think,
so -2.0001 ** 3 is hard?
On Fri, Oct 14, 2016 at 4:30 AM, Cyril Auburtin
wrote:
> I would expect `-2**3` to return -8, or `-2**2 == -4`, since it should be
> like `-(2**3)`
>
> Firefox gives
I would expect `-2**3` to return -8, or `-2**2 == -4`, since it should be
like `-(2**3)`
Firefox gives a clearer error then Chrome with:
> SyntaxError: unparenthesized unary expression can't appear on the
left-hand side of '**'
Is there a reason for this restriction? Python does it `-2**3` fine
23 matches
Mail list logo