Richard said:
Assuming that - document.Contest.Last.value - if a reference to the -
value - property of a form element then the concatenation is actually
worthless as such - value - property values are already string
primitives. Unfortunately forced type-conversion methods often ends up
being applied as a mystical incantation, and so in contexts where they
actually have no effect.
Incidentally, to force type conversion to a string primitive the String
constructor can be used without the - new - operator, as in:-
String(document.Contest.Last.value)
- Which has been both recommended against on the grounds that it could
be confused with a miss-typed - new String(s); - and recommended as a
self-documenting and explicit means of forcing type-conversion to a
string. I am leaning towards the latter. Concatenating the empty string
has been shown to be the most runtime efficient type-conversion to
string primitive operation.
There is no consensus on what is most runtime-efficient here. In fact, the
results at <
http://jsperf.com/string-conversion-speed> vary so much between
implementations, runtime environments, and even consecutive tests in the
very same runtime environment, and String() is indeed self-documenting, that
I am going to keep my original, ECMAScript-supported approach¹ of using
String() when I do not know the type of the value and if it(s object
representation) has a toString() method.
PointedEars
___________
¹) the `+' operator requires more algorithmic steps for the type conversion
than String()