Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Addressed some of the issues brought up by @jdalton in https://gist.g…
- Loading branch information
21c880d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a specific reason (aside from saving bytes) that you are using 1/0 instead of Infinity or Number.POSITIVE_INFINITY ?
21c880d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tkissing:
1/0
always produces anInfinity
value. Similar toundefined
andNaN
,Infinity
is a writeable (in most cases) global variable that initially contains anInfinity
value.21c880d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say not 'in the most cases', but only in old IEs.
http://es5.github.com/x15.1.html#x15.1.1.2
21c880d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@paulmillr: I don't know of an interpreter that disallows writing to
Infinity
outside strict mode. They all implement ES3 15.1.1.2.21c880d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kitcambridge Which environment allows overriding of
Number.POSITIVE_INFINITY
?Infinity
is a property of the global object, so I understand the objection for that. ButNumber.POSITIVE_INFINITY
should be a true constant.21c880d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tkissing: While you're right about the
POSITIVE_INFINITY
property, that's only useful if we can guarantee we have a reference to the originalNumber
constructor, which is writeable...21c880d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doh. Thanks for the explanations everyone. Guess I will have to live with the warnings during build then (or just see if I can live without any of the shims that use toInteger and remove that code).
21c880d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@michaelficarra just checked latest Spidermonkey, Nitro, Carakan & v8 in stable browsers -- no strict mode needed, Inf & undefined can't be redefined.
21c880d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@paulmillr:
A fairly recent version of
node
(v8):And I installed latest stable
node
just in case:And last time I checked v8 through chrome that behaviour existed, but you're right: it has now changed for me as well (using the latest Chrome beta build).