473,395 Members | 1,790 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Calling Array.splice({}) with no start

Array.splice({})

What should it do?

I think it should return a new Array with length 0.

Array.splice(arr, start, deleteCount [, item1 [, item2[,...]]])
http://bclary.com/2004/11/07/#a-15.4.4.12

Example:
Array.splice({})

Result:
FF3.1
function splice() { [native code] }
Webkit:
undefined
If - start - is passed in, a 0 length array is returned.

Array.prototype.splice.call(0, undefined);
Result: []

The methods that go into calculating the - length - property all call
ToNumber, either through ToUint32, or ToInteger. ToNumber coverts
undefined to NaN, which returns the value back to its caller, either
ToInteger or ToUint32, which converts NaN to +0.
It seems step 4 is not what I expect:
| 4. Call ToInteger(start).

start is omitted from the argument list, I assume this means start =
undefined.

ToInteger calls ToNumber.
ToInteger:
| 1. Call ToNumber on the input argument.
| 2. If Result(1) is NaN, return +0.
....

ToNumber returns NaN:
| 9.3 ToNumber
| The operator ToNumber converts its argument
| to a value of type Number according to the following table:
|-----------+-----+
| Undefined | NaN |
`....-------+-----+

Back to ToInteger, step 2.
| 2. If Result(1) is NaN, return +0.

Aug 19 '08 #1
18 1802
dhtml wrote:

That would be:
javascript:alert(Array.prototype.isPrototypeOf(
Array.prototype.splice.call({}) ))

Results:
Opera9.5 mac:
true
FF3.1, Webkit
false

Garrett
Aug 19 '08 #2
On 19 Aug., 07:59, dhtml <dhtmlkitc...@gmail.comwrote:
Array.splice({})

What should it do?

I think it should return a new Array with length 0.

Array.splice(arr, start, deleteCount [, item1 [, item2[,...]]])http://bclary.com/2004/11/07/#a-15.4.4.12
I'm only an occasional poster and not expert, but am I falling for a
troll here?

Array.splice({}) makes semantically absolutely no sense.

a) Splice is the method of an array object, not of the Array global
object.
b) "{}" is an empty object not an "array of the length 0".

So I guess you accually mean [].splice()

However
c) the start and deleteCount parameters are mandatory, so who cares
what the different engines return in such an undefined case?

Robin
Aug 19 '08 #3
On Aug 19, 2:40 pm, Robin Rattay wrote:
On 19 Aug., 07:59, dhtml wrote:
>Array.splice({})
>What should it do?
>I think it should return a new Array with length 0.
>Array.splice(arr, start, deleteCount [, item1 [, item2[,...]]])
http://bclary.com/2004/11/07/#a-15.4.4.12

I'm only an occasional poster and not expert, but am
I falling for a troll here?
It would have been easier to tell if the OP had actually made some
(any) point.
Array.splice({}) makes semantically absolutely no sense.

a) Splice is the method of an array object, not of the
Array global object.
That may just be a misguided use of "Array" to mean any array object.
There are certainly many less ambiguous ways to express that, if it
was the intention.
b) "{}" is an empty object not an "array of the length 0".

So I guess you accually mean [].splice()
More likely - [].slice({}) - else there would have been no point in
mentioning the handling of objects in ToInteger (which without a
modification to Object.prototype.toString/valueOf will return numeric
zero).
However
c) the start and deleteCount parameters are mandatory,
No they are not (at least in the sense that omitting them form the
method call will not result in an error and will have a predictable/
specified outcome).
so who cares what the different engines return in such
an undefined case?
If the outcome does not correspond with the specified outcome in any
given implementation then those implementers might care.
Aug 19 '08 #4
Henry wrote:
On Aug 19, 2:40 pm, Robin Rattay wrote:
>On 19 Aug., 07:59, dhtml wrote:
>>Array.splice({})
What should it do?
I think it should return a new Array with length 0.
Array.splice(arr, start, deleteCount [, item1 [, item2[,...]]])
http://bclary.com/2004/11/07/#a-15.4.4.12
I'm only an occasional poster and not expert, but am
I falling for a troll here?
No, you're trying to answer a question you don't have an answer to and
being mildly insulting in the process. What makes you think I'm a troll?
It would have been easier to tell if the OP had actually made some
(any) point.
Ah, but I asked a question.
>
>Array.splice({}) makes semantically absolutely no sense.

a) Splice is the method of an array object, not of the
Array global object.
Right, Array.splice is the generic top-level method (and 'Henry' is
likely aware). But that's why I followed up with the
Array.prototype.splice.call sample, which is standard and implemented in
more browsers.
That may just be a misguided use of "Array" to mean any array object.
Nope, just the code I was running in Firefox.
>
>b) "{}" is an empty object not an "array of the length 0".

So I guess you accually mean [].splice()

More likely - [].slice({}) -
No, I meat exactly what I wrote, and if you'd tried it, you might have
noticed that Array.splice({}) in Firefox, returns the splice function
itself like I wrote. Did you try it?
>However
c) the start and deleteCount parameters are mandatory,

No they are not (at least in the sense that omitting them form the
method call will not result in an error and will have a predictable/
specified outcome).
>so who cares what the different engines return in such
an undefined case?

If the outcome does not correspond with the specified outcome in any
given implementation then those implementers might care.
The question is: "What is the specified output when 'start' is absent?"

Its a somewhat obscure question. I think it should be the array created
in step 1. Webkit and Firefox give different results.

Related thread:
http://groups.google.com/group/comp....8?dmode=source

Regarding step 4 of Array.prototype.splice, if the 'start' argument is
not present, it should be assumed to be undefined, right? This lead
through several more steps, which should result in step 54 returning A.

Garrett
Aug 19 '08 #5
On Aug 19, 6:50 pm, dhtml wrote:
Henry wrote:
>On Aug 19, 2:40 pm, Robin Rattay wrote:
>>On 19 Aug., 07:59, dhtml wrote:
Array.splice({})
What should it do?
It would have been easier to tell if the OP had actually
made some
(any) point.

Ah, but I asked a question.
If you mean your question was "what should a non-standard language
extension that only exists in a few of implementations do?" then the
answer is "anything it likes, and not necessarily the same thing as
any other non-standard extension that resembles it".
>>Array.splice({}) makes semantically absolutely no sense.
>>a) Splice is the method of an array object, not of the
Array global object.

Right, Array.splice is the generic top-level method
There is no "the" about it. If there is an - Array.splice - at all
then it is a non-standard language extension.
(and 'Henry' is
likely aware). But that's why I followed up with the
Array.prototype.splice.call sample, which is standard
and implemented in more browsers.
Is it? I did wonder what the point of that follow up was, particularly
as you switched from using an array literal as the argument to splice
to not providing any arguments at all.
>That may just be a misguided use of "Array" to mean any
array object.

Nope, just the code I was running in Firefox.
So it was actually a pointless question; it is generally not viable to
use non-standard language extensions in non-known environment contexts
(as they are unlikely to be either universally or consistently
implemented) and if you have a know environment you can determine the
answer for that context on your own.
>>b) "{}" is an empty object not an "array of the length 0".
>>So I guess you accually mean [].splice()
>More likely - [].slice({}) -

No, I meat exactly what I wrote, and if you'd tried it, you
might have noticed that Array.splice({}) in Firefox, returns
the splice function itself like I wrote.
You did not write that.
Did you try it?
No, why should I as you made no relevant point?

<snip>
The question is: "What is the specified output when 'start'
is absent?"
<snip>

With - Array.prototype.slice -, an empty array.
With - Array.slice -, ask the people who wrote it.
Aug 19 '08 #6
Henry wrote:
On Aug 19, 6:50 pm, dhtml wrote:
>Henry wrote:
>>On Aug 19, 2:40 pm, Robin Rattay wrote:
On 19 Aug., 07:59, dhtml wrote:
[snip]
>>>b) "{}" is an empty object not an "array of the length 0".
So I guess you accually mean [].splice()
More likely - [].slice({}) -
No, I meat exactly what I wrote, and if you'd tried it, you
might have noticed that Array.splice({}) in Firefox, returns
the splice function itself like I wrote.

You did not write that.
Anyone can read that first post:
| Example:
| Array.splice({})
|
|Result:
| FF3.1
| function splice() { [native code] }
|

Firefox 3.1 returning the splice function itself.

The funny thing is, is that if -undefined- is passed in, it works as
expected in Firefox.

javascript:var ap = Array.prototype;
alert(ap.isPrototypeOf(ap.splice.call({})));
FF3.1, Webkit: false
Opera: true

javascript:alert(ap.isPrototypeOf(ap.splice.call({ }, undefined)));
FF3.1, Webkit: true
Opera: true

I think Opera is getting this right. I've read through the steps of the
algorithm an the Array created in step 1 should be returned in step 54.
If I'm not mistaken, that's the only Return.

Garrett
Aug 19 '08 #7
dhtml wrote:
Henry wrote:
>On Aug 19, 6:50 pm, dhtml wrote:
>>Henry wrote:
On Aug 19, 2:40 pm, Robin Rattay wrote:
On 19 Aug., 07:59, dhtml wrote:

[snip]
>>>>b) "{}" is an empty object not an "array of the length 0".
So I guess you accually mean [].splice()
More likely - [].slice({}) -
No, I meat exactly what I wrote, and if you'd tried it, you
might have noticed that Array.splice({}) in Firefox, returns
the splice function itself like I wrote.
You did not write that.

Anyone can read that first post:
| Example:
| Array.splice({})
|
|Result:
| FF3.1
| function splice() { [native code] }
|

Firefox 3.1 returning the splice function itself.
Firefox 3.1 is already released? Time flies ...
The funny thing is, is that if -undefined- is passed in, it works as
expected in Firefox.

javascript:var ap = Array.prototype;
alert(ap.isPrototypeOf(ap.splice.call({})));
FF3.1, Webkit: false
Opera: true

javascript:alert(ap.isPrototypeOf(ap.splice.call({ }, undefined)));
FF3.1, Webkit: true
Opera: true

I think Opera is getting this right. I've read through the steps of the
algorithm an the Array created in step 1 should be returned in step 54.
If I'm not mistaken, that's the only Return.
You don't get it, do you? The language standard makes the first two
arguments of the method *mandatory*, so if an implementation does not error
out if one or both are missing, there is no telling if the return value is
the right or wrong one because there is nothing to base that assessment on.

And Array.splice() is certainly not the same as Array.prototype.splice().
PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>
Aug 19 '08 #8
Thomas 'PointedEars' Lahn wrote:
dhtml wrote:
>Henry wrote:
>>On Aug 19, 6:50 pm, dhtml wrote:
Henry wrote:
On Aug 19, 2:40 pm, Robin Rattay wrote:
>On 19 Aug., 07:59, dhtml wrote:
You don't get it, do you? The language standard makes the first two
arguments of the method *mandatory*,
Apparently I missed the line in the spec that says 'The first two
arguments are necessary.'

About the closest I can get to supporting your claim is:

| When the splice method is called with
| two or more arguments start...
| The following steps are taken:

Which could mean that: The algorithm applies under the conditions of
both -start- and -deleteCount- being present. Or, the sentences could be
taken separately.

The wording isn't clear.

so if an implementation does not error
out if one or both are missing, there is no telling if the return value is
the right or wrong one because there is nothing to base that assessment on.
There's the algorithm for splice. Did you read it?
And Array.splice() is certainly not the same as Array.prototype.splice().
It's actually the same code in the engine, but that's really beside the
point.

Please try to keep this thread focused and not destroy it.

Garrett
>
PointedEars
Aug 19 '08 #9
dhtml wrote:
Thomas 'PointedEars' Lahn wrote:
>You don't get it, do you? The language standard makes the first two
arguments of the method *mandatory*,

Apparently I missed the line in the spec that says 'The first two
arguments are necessary.' [...]
*Obviously*.

| 15.4.4.12 Array.prototype.splice (start, deleteCount [ , item1 [ , item2 [
| , … ] ] ] )

Brackets usually mark optional arguments/parameters, and they do so there.
PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>
Aug 20 '08 #10
Thomas 'PointedEars' Lahn wrote:
dhtml wrote:
>Thomas 'PointedEars' Lahn wrote:
>>You don't get it, do you? The language standard makes the first two
arguments of the method *mandatory*,
Apparently I missed the line in the spec that says 'The first two
arguments are necessary.' [...]

*Obviously*.

| 15.4.4.12 Array.prototype.splice (start, deleteCount [ , item1 [ , item2 [
| , … ] ] ] )

Brackets usually mark optional arguments/parameters, and they do so there.
Usually. But the spec has examples of sections that don't seem to follow
that convention. For example:

What about slice:
15.4.4.10 Array.prototype.slice(start, end)

or sort:
15.4.4.11 Array.prototype.sort(comparefn)

These don't have brackets around optional arguments. The arguments are
optional in all modern (non-beta) implementations.

slice is very commonly used to convert an object to an array, and is
often used with no arguments. For example:

Array.prototype.slice.call(arguments);

There is a general rule established by most (if not all) other methods
that if an argument is missing, it is treated as undefined.

The "optional arguments are bracketed" rule is not mentioned in the
Notational Conventions section, nor is there any text in the document
that says what should happen if an argument is missing.

Garrett
>
PointedEars
Aug 20 '08 #11
dhtml wrote:
Thomas 'PointedEars' Lahn wrote:
>dhtml wrote:
>>Thomas 'PointedEars' Lahn wrote:
You don't get it, do you? The language standard makes the first two
arguments of the method *mandatory*,
Apparently I missed the line in the spec that says 'The first two
arguments are necessary.' [...]
*Obviously*.

| 15.4.4.12 Array.prototype.splice (start, deleteCount [ , item1 [ , item2 [
| , … ] ] ] )

Brackets usually mark optional arguments/parameters, and they do so there.

Usually. But the spec has examples of sections that don't seem to follow
that convention. For example:

What about slice:
15.4.4.10 Array.prototype.slice(start, end)

or sort:
15.4.4.11 Array.prototype.sort(comparefn)

These don't have brackets around optional arguments. The arguments are
optional in all modern (non-beta) implementations.
Non sequitur.

In the first case, either you are observing unspecified behavior or the
specification prose has to be considered too imprecise there as the provided
evidence shows.

In the second case, there is "If comparefn is not undefined" and "Otherwise
the following steps are taken." which would indicate that this argument of
this method is optional since according to section 10.1.3 extra formal
parameters have the value `undefined'.

Please do not quote signatures unless you refer to them.
PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
Aug 20 '08 #12
Thomas 'PointedEars' Lahn wrote:
dhtml wrote:
>Thomas 'PointedEars' Lahn wrote:
>>dhtml wrote:
Thomas 'PointedEars' Lahn wrote:
You don't get it, do you? The language standard makes the first two
arguments of the method *mandatory*,
Apparently I missed the line in the spec that says 'The first two
arguments are necessary.' [...]
*Obviously*.

| 15.4.4.12 Array.prototype.splice (start, deleteCount [ , item1 [ , item2 [
| , … ] ] ] )

Brackets usually mark optional arguments/parameters, and they do so there.
Usually. But the spec has examples of sections that don't seem to follow
that convention. For example:

What about slice:
15.4.4.10 Array.prototype.slice(start, end)

or sort:
15.4.4.11 Array.prototype.sort(comparefn)

These don't have brackets around optional arguments. The arguments are
optional in all modern (non-beta) implementations.

Non sequitur.
Shows that optional arguments are treated as undefined.
In the first case, either you are observing unspecified behavior or the
specification prose has to be considered too imprecise there as the provided
evidence shows.
It is the case that slice treats the unspecified params as undefined.
>
In the second case, there is "If comparefn is not undefined" and "Otherwise
the following steps are taken." which would indicate that this argument of
this method is optional since according to section 10.1.3 extra formal
parameters have the value `undefined'.
Right. As stated in 10.1.3, if the caller supplies fewer parameters than
formal parameters, the extra parameter variables have the value
undefined. And splice() is a function.

IOW, When an argument is absent, undefined is used as the value. The
only exception I find is FF/Webkit's implentation splice. Both treat
"argument missing" as something different from undefined.

[].splice.call({})
FF3, Webkit both return undefined
Opera 9.5 returns 0 length array.
[].splice.call({},undefined)
FF3, Webkit, Opera 9.5 all return a 0 length array.

Garrett

Please do not quote signatures unless you refer to them.
PointedEars
Aug 21 '08 #13
dhtml wrote:
Thomas 'PointedEars' Lahn wrote:
>dhtml wrote:
>>Thomas 'PointedEars' Lahn wrote:
dhtml wrote:
Thomas 'PointedEars' Lahn wrote:
[].splice.call({})
FF3, Webkit both return undefined
FF3 returns the splice function.
Opera 9.5 returns 0 length array.
[].splice.call({},undefined)
FF3, Webkit, Opera 9.5 all return a 0 length array.

Garrett
>>
PointedEars
Aug 21 '08 #14
dhtml wrote:
Thomas 'PointedEars' Lahn wrote:
>dhtml wrote:
>>Thomas 'PointedEars' Lahn wrote:
dhtml wrote:
Thomas 'PointedEars' Lahn wrote:
>You don't get it, do you? The language standard makes the first two
>arguments of the method *mandatory*,
Apparently I missed the line in the spec that says 'The first two
arguments are necessary.' [...]
*Obviously*.

| 15.4.4.12 Array.prototype.splice (start, deleteCount [ , item1 [ , item2 [
| , … ] ] ] )

Brackets usually mark optional arguments/parameters, and they do so there.
Usually. But the spec has examples of sections that don't seem to follow
that convention. For example:

What about slice:
15.4.4.10 Array.prototype.slice(start, end)

or sort:
15.4.4.11 Array.prototype.sort(comparefn)

These don't have brackets around optional arguments. The arguments are
optional in all modern (non-beta) implementations.
Non sequitur.

Shows that optional arguments are treated as undefined.
If anything, it shows that that the specification is worded imprecisely.
Which point are you trying to make here? It was never debated that formal
parameters for which no value has been passed are treated as undefined *on
call*, that is what is specified. (Why did you reiterate that anyway?)

But what that means for the underlying algorithm of the method and therefore
for its return value, is an entirely different matter. If the Specification
does not say how an implementation is supposed to behave in such a case, it
is wrong to say that one implementation is correct and another one is not
just because the outcomes differ.
>Please do not quote signatures unless you refer to them.

PointedEars
^^^^^^^^^^^
Which part of that did you not get?
PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>
Aug 21 '08 #15
Thomas 'PointedEars' Lahn wrote:
dhtml wrote:
>Thomas 'PointedEars' Lahn wrote:
>>dhtml wrote:
Thomas 'PointedEars' Lahn wrote:
dhtml wrote:
>Thomas 'PointedEars' Lahn wrote:
>>You don't get it, do you? The language standard makes the first two
>>arguments of the method *mandatory*,
>Apparently I missed the line in the spec that says 'The first two
>arguments are necessary.' [...]
*Obviously*.
>
| 15.4.4.12 Array.prototype.splice (start, deleteCount [ , item1 [ , item2 [
| , … ] ] ] )
>
Brackets usually mark optional arguments/parameters, and they do so there.
Usually. But the spec has examples of sections that don't seem to follow
that convention. For example:

What about slice:
15.4.4.10 Array.prototype.slice(start, end)

or sort:
15.4.4.11 Array.prototype.sort(comparefn)

These don't have brackets around optional arguments. The arguments are
optional in all modern (non-beta) implementations.
Non sequitur.
Shows that optional arguments are treated as undefined.

If anything, it shows that that the specification is worded imprecisely.
Which point are you trying to make here?
Weren't you saying that non-square bracketed arguments were mandatory?

You inferred that 'square brackets means optional'. Then you seemed to
deny the antecedent of that inference with: if a parameter is non-square
bracketed, it is *mandatory* is faulty logic.

1. squares bracket not defined/documented.
2. other methods w/no square brackets around arguments use undefined for
missing arguments.

The square brackets don't have a defined meaning.

It was never debated that formal
parameters for which no value has been passed are treated as undefined *on
call*, that is what is specified. (Why did you reiterate that anyway?)

But what that means for the underlying algorithm of the method and therefore
for its return value, is an entirely different matter. If the Specification
does not say how an implementation is supposed to behave in such a case, it
is wrong to say that one implementation is correct and another one is not
just because the outcomes differ.
It sounds like you're still arguing that the underlying algorithm is
allowed to implement unique behavior when non-square bracketed arguments
are omitted. I don't see any grounds for this argument, in practice, or
in the spec.

It seems most reasonable to go with the behavior that is set forth in
10.1.3. Since implementations do this for non-square bracketed arguments
of all other methods, it is safe to say that it is a rule. The value
undefined should be used for a missing parameter, regardless of square
brackets.

Garrett
>
>>Please do not quote signatures unless you refer to them.

PointedEars
^^^^^^^^^^^
Which part of that did you not get?
PointedEars
Aug 22 '08 #16
dhtml wrote:
Thomas 'PointedEars' Lahn wrote:
>dhtml wrote:
>>Thomas 'PointedEars' Lahn wrote:
dhtml wrote:
Thomas 'PointedEars' Lahn wrote:
>dhtml wrote:
>>Thomas 'PointedEars' Lahn wrote:
>>>You don't get it, do you? The language standard makes the
>>>first two arguments of the method *mandatory*,
>>Apparently I missed the line in the spec that says 'The first
>>two arguments are necessary.' [...]
>*Obviously*.
>>
>| 15.4.4.12 Array.prototype.splice (start, deleteCount [ ,
>item1 [ , item2 [ | , … ] ] ] )
>>
>Brackets usually mark optional arguments/parameters, and they
>do so there.
Usually. But the spec has examples of sections that don't seem to
follow that convention. For example:
>
What about slice: 15.4.4.10 Array.prototype.slice(start, end)
>
or sort: 15.4.4.11 Array.prototype.sort(comparefn)
>
These don't have brackets around optional arguments. The
arguments are optional in all modern (non-beta) implementations.
Non sequitur.
Shows that optional arguments are treated as undefined.
If anything, it shows that that the specification is worded
imprecisely. Which point are you trying to make here?

Weren't you saying that non-square bracketed arguments were mandatory?
Not so, I did not.
The square brackets don't have a defined meaning.
Yes, they have.
>It was never debated that formal parameters for which no value has been
passed are treated as undefined *on call*, that is what is specified.
(Why did you reiterate that anyway?)

But what that means for the underlying algorithm of the method and
therefore for its return value, is an entirely different matter. If
the Specification does not say how an implementation is supposed to
behave in such a case, it is wrong to say that one implementation is
correct and another one is not just because the outcomes differ.

It sounds like you're still arguing that the underlying algorithm is
allowed to implement unique behavior when non-square bracketed arguments
are omitted.
Again, for the intellectually challenged among us: I am arguing instead that
brackets would give an indication as to which arguments are optional and
which are not; however, as the Specification is obviously worded
imprecisely, the Specification prose also counts. If there is nothing in
the prose/algorithm of a method to define what is to be done when certain
arguments are omitted, it is not reasonable to call one return value wrong
and one right. Period.
I don't see any grounds for this argument, in practice, or in the spec.

It seems most reasonable to go with the behavior that is set forth in
10.1.3. Since implementations do this for non-square bracketed arguments
of all other methods, it is safe to say that it is a rule. The value
undefined should be used for a missing parameter, regardless of square
brackets.
Non sequitur. You misunderstood completely what I was saying; given your
other luser-like behavior, maybe on purpose:
[quoting unreferred parts including my signature again]
Score adjusted

PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>
Aug 22 '08 #17
In comp.lang.javascript message <48**************@PointedEars.de>, Thu,
21 Aug 2008 23:34:43, Thomas 'PointedEars' Lahn <Po*********@web.de>
posted:
>
>>Please do not quote signatures unless you refer to them.

PointedEars
^^^^^^^^^^^
Which part of that did you not get?
PointedEars
It's not a signature. Signatures are preceded by a signature delimiter.

--
(c) John Stockton, nr London UK. replyYYWW merlyn demon co uk Turnpike 6.05.
Web <URL:http://www.uwasa.fi/~ts/http/tsfaq.html-Timo Salmi: Usenet Q&A.
Web <URL:http://www.merlyn.demon.co.uk/news-use.htm: about usage of News.
No Encoding. Quotes precede replies. Snip well. Write clearly. Mail no News.
Aug 22 '08 #18
Thomas 'PointedEars' Lahn wrote:
dhtml wrote:
>Thomas 'PointedEars' Lahn wrote:
>>dhtml wrote:
Thomas 'PointedEars' Lahn wrote:
dhtml wrote:
>Thomas 'PointedEars' Lahn wrote:
>>dhtml wrote:
>>>Thomas 'PointedEars' Lahn wrote:
>>>>You don't get it, do you? The language standard makes the
>>>>first two arguments of the method *mandatory*,
>>>Apparently I missed the line in the spec that says 'The first
>>>two arguments are necessary.' [...]
>>*Obviously*.
>>>
>>| 15.4.4.12 Array.prototype.splice (start, deleteCount [ ,
>>item1 [ , item2 [ | , … ] ] ] )
>>>
>>Brackets usually mark optional arguments/parameters, and they
>>do so there.
>Usually. But the spec has examples of sections that don't seem to
>follow that convention. For example:
>>
>What about slice: 15.4.4.10 Array.prototype.slice(start, end)
>>
>or sort: 15.4.4.11 Array.prototype.sort(comparefn)
>>
>These don't have brackets around optional arguments. The
>arguments are optional in all modern (non-beta) implementations.
Non sequitur.
Shows that optional arguments are treated as undefined.
If anything, it shows that that the specification is worded
imprecisely. Which point are you trying to make here?
Weren't you saying that non-square bracketed arguments were mandatory?

Not so, I did not.
>The square brackets don't have a defined meaning.

Yes, they have.
So what is clearly defined meaning?
>
>>It was never debated that formal parameters for which no value has been
passed are treated as undefined *on call*, that is what is specified.
(Why did you reiterate that anyway?)

But what that means for the underlying algorithm of the method and
therefore for its return value, is an entirely different matter. If
the Specification does not say how an implementation is supposed to
behave in such a case, it is wrong to say that one implementation is
correct and another one is not just because the outcomes differ.
It sounds like you're still arguing that the underlying algorithm is
allowed to implement unique behavior when non-square bracketed arguments
are omitted.

Again, for the intellectually challenged among us: I am arguing instead that
brackets would give an indication as to which arguments are optional and
which are not;
So the "clearly defined meaning" is the argument of Thomas 'PointedEars'
Lahn.

however, as the Specification is obviously worded
imprecisely, the Specification prose also counts. If there is nothing in
the prose/algorithm of a method to define what is to be done when certain
arguments are omitted, it is not reasonable to call one return value wrong
and one right. Period.
>I don't see any grounds for this argument, in practice, or in the spec.

It seems most reasonable to go with the behavior that is set forth in
10.1.3. Since implementations do this for non-square bracketed arguments
of all other methods, it is safe to say that it is a rule. The value
undefined should be used for a missing parameter, regardless of square
brackets.

Non sequitur. You misunderstood completely what I was saying;
I'm not sure that anyone understood completely what you were saying.
Sprinkling your argument with put downs doesn't exactly make it clearer.

given your
other luser-like behavior, maybe on purpose:
>[quoting unreferred parts including my signature again]

Score adjusted
Uh oh. not that again. Thomas, I am trying to engage in a normal
conversation with you. But you seem to be resisting that. I think that's
a bad choice. I thought you wanted to be FAQ maintainer. What happened?

Garrett
PointedEars
Aug 23 '08 #19

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Tek9_AK | last post by:
I need to find a way to transfer all the values of an array inside a function out of the fuction into another array. IE function splice($filename){ if(file_exists($filename)){...
12
by: Sam Collett | last post by:
How do I remove an item with a specified value from an array? i.e. array values 1,2,2,5,7,12,15,21 remove 2 from array would return 1,5,7,12,15,21 (12 and 21 are NOT removed, duplicates are...
5
by: effendi | last post by:
I wrote a simple script to remove an element of an array but I don't think this is the best way to go about it. I have a list of about five elements seperated by ";" I split the array using...
15
by: alanbe | last post by:
Greetings I am making a flashcard type application to help me in my TCP/IP protocols test. My instructor will test us periodically on how a device or networking function relates to the OSI...
2
by: BrianP | last post by:
Hi, I have had to invent a work-around to get past what looks like a JavaScript bug, the malfunctioning Perl-like JavaScript array functions including SPLICE() and UNSHIFT(). I have boiled it...
3
by: Newcomsas | last post by:
Hello, I'm trying to solve a problem with JS textbox array without success. I have two buttons in my page: PLUS and MINUS; at every click on PLUS a new textbox named 'dear' is generated. So, if...
24
by: RyanTaylor | last post by:
I have a final coming up later this week in my beginning Java class and my prof has decided to give us possible Javascript code we may have to write. Problem is, we didn't really cover JS and what...
19
by: brasilino | last post by:
Hi Folks: I've been looking (aka googling) around with no success. I need a usability beyond 'pop()' method when removing an Array elements. For example: oName = new...
1
by: agendum97 | last post by:
MSDN says splice has the following arguments: arrayObj.splice(start, deleteCount, ]]]) Thus I can insert items into an array using splice. But how do I insert an entire array? For example:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.