On Jun 1, 9:52 pm, RubyRedRick <rick.denat...@gmail.comwrote:
Quote:
So is the first argument to slice really optional despite the various
doc's I've checked (including and besides the book in question), or
are Firefox and Safari both working outside of the JS spec here, or is
there something else I'm missing?
The docs are wrong: at least for an engine strictly implementing the
relevant ECMA-262 internal algorithms.
Array slice method production:
15.4.4.10
....
4. Call ToInteger(start).
5. If Result(4) is negative, use max((Result(3)+Result(4)),0); else
use min(Result(4),Result(3)).
Internal ToInteger production:
9.4 ToInteger
1. Call ToNumber on the input argument.
2. If Result(1) is NaN, return +0.
....
This way slice() without arguments still will equal to slice(0) so
still be working. This is what I don't like rather often in
Crockford's approaches: they are bearing to much of mannerism for my
blood, to much of coding just for coding. Respectively sometimes
_unnecessary_ dependence on strict engine implementations. Does it
kill anyone to provide the argument? Why to transform a business
solution into some kind of engine's acid test? It is strictly my
opinion and the book contains an ocean of interesting approaches. Just
be warned that it is not a book I would recomment to anyone to learn
javascript
: it is for advanced programmers willing to improve their
skills. Again strictly IMHO.