[Webkit-unassigned] [Bug 131707] Simple ES6 feature: Number constructor extras

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Sat Sep 27 03:32:29 PDT 2014


https://bugs.webkit.org/show_bug.cgi?id=131707





--- Comment #32 from Diego Pino <dpino at igalia.com>  2014-09-27 03:32:24 PST ---
(In reply to comment #30)
> (From update of attachment 238593 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=238593&action=review
> 
> > LayoutTests/js/script-tests/number-constructor.js:22
> > +shouldBeFalse('Number.isFinite(undefined)');
> 
> Just for your information, there is no keyword “undefined”. This just works because undefined is not the name of any variable or property. Could also be “foo”, which is also undefined.

I looked a bit into this. It seems "undefined" is a property of the global object, so it's a variable in the global scope. The value of "undefined" is the primitive value undefined. You're correct when you say "undefined" is not a reserved-word in JavaScript. It would be possible to do "var undefined = 10;", although this property of the global object is non-writable, non-configurable, so it has no effect.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined

Number.isFinite(foo) wouldn't work because "foo" is not defined as a variable yet (throws Exception ReferenceError). Number.isFinite(undefined) is the same as Number.isFinite(), in both cases the argument the function isFinite(x) receives will be undefined.

For all the functions (except in the cases of parseInt and parseFloat), there was already a test for testing a function without arguments and calling it with "undefined" . Since it is the same thing, I will remove the "undefined" calls. I will add a test for calling a function with a not defined variable, should throw an Exception.

> 
> > LayoutTests/js/script-tests/number-constructor.js:64
> > +shouldBeFalse('Number.isNaN(false)');
> 
> true?
> 

Correct.

> > LayoutTests/js/script-tests/number-constructor.js:121
> > +shouldBe('Number.parseFloat(null)', 'NaN');
> 
> no test of undefined for parseFloat?
>

Same thing as Number.parseFloat().

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


More information about the webkit-unassigned mailing list