FAQ Updated
The entry for "How do I suppress a context menu (right-click menu)?" was
rewritten with feedback and commentary from Stockton and entries were
reorganized as discussed in "Retrieve a Radio Button Value", raised by RobG.
--
Garrett
|
|
0
|
|
|
|
Reply
|
Garrett
|
10/5/2010 7:19:55 AM |
|
In comp.lang.javascript message <i8ejis$hf4$1@news.eternal-
september.org>, Tue, 5 Oct 2010 00:19:55, Garrett Smith
<dhtmlkitchen@gmail.com> posted:
>FAQ Updated
>
>The entry for "How do I suppress a context menu (right-click menu)?"
>was rewritten with feedback and commentary from Stockton and entries
>were reorganized as discussed in "Retrieve a Radio Button Value",
>raised by RobG.
You _STILL_ have not fixed the erroneous 0.07 in Section 6.1.
Section 6.3 :
In an integer context "between 2 and 36" means "3 to 35 inclusive". Use
"from 2 to 36" which is correct and shorter.
Lacks mention of leading sign and/or whitespace.
Does not acknowledge ECMA 262 5th Edn, Annex E, 15.1.2.2.
Section 6.4 :
"Since plus (+) is also used as in string concatenation, '1' + 1 is
equal to '11'." is (or contains) a /non sequitur/.
Section 7.1 :
Para 3 should be "Examples". It would be better to include that word in
the comment in the box : "// Examples of native ..."
<FAQENTRY> "How to create a Date Object?"
Unless it is necessary to capture the current date/time as 'new Date()',
or to create a Date Object with some other particular date/time value,
use 'new Date(0)' or 'new Date(NaN)'. The latter are faster, and always
get the same value so avoiding possible date-dependent bugs.
--
(c) John Stockton, nr London, UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME.
Web <http://www.merlyn.demon.co.uk/> - FAQqish topics, acronyms and links;
Astro stuff via astron-1.htm, gravity0.htm ; quotings.htm, pascal.htm, etc.
No Encoding. Quotes before replies. Snip well. Write clearly. Don't Mail News.
|
|
0
|
|
|
|
Reply
|
Dr
|
10/6/2010 7:45:44 PM
|
|
On 2010-10-06 12:45 PM, Dr J R Stockton wrote:
> In comp.lang.javascript message<i8ejis$hf4$1@news.eternal-
> september.org>, Tue, 5 Oct 2010 00:19:55, Garrett Smith
> <dhtmlkitchen@gmail.com> posted:
>
>> FAQ Updated
>>
>> The entry for "How do I suppress a context menu (right-click menu)?"
>> was rewritten with feedback and commentary from Stockton and entries
>> were reorganized as discussed in "Retrieve a Radio Button Value",
>> raised by RobG.
>
>
> You _STILL_ have not fixed the erroneous 0.07 in Section 6.1.
>
OK, I've changed that to:
| ECMA-262 3rd Edition introduced `Number.prototype.toFixed`. There are
| bugs in JScript 5.8 and below with certain numbers, for example
`0.007.toFixed(2)` incorrectly results `0.00`.
>
>
> Section 6.3 :
>
> In an integer context "between 2 and 36" means "3 to 35 inclusive". Use
> "from 2 to 36" which is correct and shorter.
>
OK, fixed that.
> Lacks mention of leading sign and/or whitespace.
>
Correct.
> Does not acknowledge ECMA 262 5th Edn, Annex E, 15.1.2.2.
>
Doesn't mention Ed 3 either.
> Section 6.4 :
> "Since plus (+) is also used as in string concatenation, '1' + 1 is
> equal to '11'." is (or contains) a /non sequitur/.
>
How so?
> Section 7.1 :
> Para 3 should be "Examples". It would be better to include that word in
> the comment in the box : "// Examples of native ..."
>
I believe it would be better for "Example:" to be bolded.
>
>
> <FAQENTRY> "How to create a Date Object?"
>
> Unless it is necessary to capture the current date/time as 'new Date()',
> or to create a Date Object with some other particular date/time value,
> use 'new Date(0)' or 'new Date(NaN)'. The latter are faster, and always
> get the same value so avoiding possible date-dependent bugs.
>
Good to know and good advice.
If others feel it should be definitely added, I'll add it.
I might rather see the (large and growing) FAQ broken up into multiple
documents. That would be a bit of work.
--
Garrett
|
|
0
|
|
|
|
Reply
|
Garrett
|
10/7/2010 4:29:41 AM
|
|
In comp.lang.javascript message <i8jibh$n3o$1@news.eternal-
september.org>, Wed, 6 Oct 2010 21:29:41, Garrett Smith
<dhtmlkitchen@gmail.com> posted:
>On 2010-10-06 12:45 PM, Dr J R Stockton wrote:
>> In comp.lang.javascript message<i8ejis$hf4$1@news.eternal-
>> september.org>, Tue, 5 Oct 2010 00:19:55, Garrett Smith
>> <dhtmlkitchen@gmail.com> posted:
>>
>>> FAQ Updated
Section 6.3 now has "(from between 2 to 36)". That is nonsense. Remove
the "between".
>> Lacks mention of leading sign and/or whitespace.
>>
>
>Correct.
Without such a mention, the entry is incorrect.
>> Does not acknowledge ECMA 262 5th Edn, Annex E, 15.1.2.2.
>
>Doesn't mention Ed 3 either.
3rd Edn lacks an Annex E.
5th Edn requires "09" to convert to +9.
All my current browsers convert "09" to 0 (I presume +0), though for a
while Opera gave +9.
The FAQ should point out that while at present browsers give zero, there
must be a risk that they will become ECMA-compliant.
>> Section 6.4 :
>> "Since plus (+) is also used as in string concatenation, '1' + 1 is
>> equal to '11'." is (or contains) a /non sequitur/.
>>
>
>How so?
Well, assuming that you know what /non sequitur/ means, it should be
obvious. The truth of the portion of the sentence before the comma does
not *necessitate* the truth of the portion of the sentence after the
comma. It would have been possible to define + as addition, except only
when both sides are strings. Therefore, there should be no actual or
implied "since".
Should be "Because plus (+) concatenates if one or both operands of the
binary plus operator is a string, '1' + 1 gives '11'." with maybe "plus
adds if both operands are numbers".
>> Section 7.1 :
>> Para 3 should be "Examples". It would be better to include that word in
>> the comment in the box : "// Examples of native ..."
>>
>
>I believe it would be better for "Example:" to be bolded.
No. It needs to be plural, and there is no need for it to be outside
the box..
>> <FAQENTRY> "How to create a Date Object?"
>>
>> Unless it is necessary to capture the current date/time as 'new Date()',
>> or to create a Date Object with some other particular date/time value,
>> use 'new Date(0)' or 'new Date(NaN)'. The latter are faster, and always
>> get the same value so avoiding possible date-dependent bugs.
>>
>Good to know and good advice.
>
>If others feel it should be definitely added, I'll add it.
There "always get" should be "each always gets".
>I might rather see the (large and growing) FAQ broken up into multiple
>documents. That would be a bit of work.
ISTM better to have it all in one document; 100kB is not long nowadays.
It could be reduced in size by more adept wording, and by putting the
bulk of 10.3 elsewhere (it is 5.7K of displayed characters, plus its
HTML overhead), and maybe likewise with similar cases.
An oldish copy of TIDY reports a few warnings for the current FAQ,
mostly empty <p>. Opera 10.62 Ctrl-Alt-Shift-U validation gives an
error message (I'm not sure whether it refers to the testing process or
to the tested page). But http://validator.w3.org/ likes it.
--
(c) John Stockton, nr London UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME.
Web <http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, and links.
Proper <= 4-line sig. separator as above, a line exactly "-- " (RFCs 5536/7)
Do not Mail News to me. Before a reply, quote with ">" or "> " (RFCs 5536/7)
|
|
0
|
|
|
|
Reply
|
Dr
|
10/8/2010 9:31:30 PM
|
|
On 2010-10-08 02:31 PM, Dr J R Stockton wrote:
> In comp.lang.javascript message<i8jibh$n3o$1@news.eternal-
> september.org>, Wed, 6 Oct 2010 21:29:41, Garrett Smith
> <dhtmlkitchen@gmail.com> posted:
>
>> On 2010-10-06 12:45 PM, Dr J R Stockton wrote:
>>> In comp.lang.javascript message<i8ejis$hf4$1@news.eternal-
>>> september.org>, Tue, 5 Oct 2010 00:19:55, Garrett Smith
>>> <dhtmlkitchen@gmail.com> posted:
>>>
>>>> FAQ Updated
>
> Section 6.3 now has "(from between 2 to 36)". That is nonsense. Remove
> the "between".
Right.
>
>
>>> Lacks mention of leading sign and/or whitespace.
>>>
>>
>> Correct.
>
> Without such a mention, the entry is incorrect.
I recall proposing the idea but it either got a tepid response or
criticism. In the source comment, I have:
If base 10 is desired,
the unary <ICODE>+</ICODE> operator can be an option. Example:
var s = '-09.1'; // Input string.
var j = +s; // Convert to number. Result: -9.1
var n = j|0; // Chop off decimal (convert ToInt32). Result: -9
Anyway, conversion to number is covered in "why does 1 + 1 equal 11?"
and more in-depth in the notes article.
>
>
>
>>> Does not acknowledge ECMA 262 5th Edn, Annex E, 15.1.2.2.
>>
>> Doesn't mention Ed 3 either.
>
> 3rd Edn lacks an Annex E.
>
That it does, however, although edition 3 permitted octal
interpretation, it recommended implementations against doing that.
And I see DevMo page for parseInt has not been updated for ES5.
<https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/parseInt>
> 5th Edn requires "09" to convert to +9.
>
Now it is required.
> All my current browsers convert "09" to 0 (I presume +0), though for a
> while Opera gave +9.
>
That's odd. Opera took the ES3 recommendation but now that ES5 is out,
Opera violates that.
> The FAQ should point out that while at present browsers give zero, there
> must be a risk that they will become ECMA-compliant.
>
That is a very strange way of looking at it.
>
>>> Section 6.4 :
>>> "Since plus (+) is also used as in string concatenation, '1' + 1 is
>>> equal to '11'." is (or contains) a /non sequitur/.
>>>
>>
>> How so?
>
> Well, assuming that you know what /non sequitur/ means, it should be
> obvious. The truth of the portion of the sentence before the comma does
> not *necessitate* the truth of the portion of the sentence after the
> comma. It would have been possible to define + as addition, except only
> when both sides are strings. Therefore, there should be no actual or
> implied "since".
>
The + operator performs concatenation if either operand is a string,
thus `'1' + 1` results "11".
> Should be "Because plus (+) concatenates if one or both operands of the
> binary plus operator is a string, '1' + 1 gives '11'." with maybe "plus
> adds if both operands are numbers".
>
But that's incomplete.
true + true == 2;
1 + {valueOf:function(){return 1}} == 2;
yet 1 + new Date is a string. I d
|
|
0
|
|
|
|
Reply
|
Garrett
|
10/9/2010 3:23:02 AM
|
|
In comp.lang.javascript message <i8on6j$8ek$1@news.eternal-
september.org>, Fri, 8 Oct 2010 20:23:02, Garrett Smith
<dhtmlkitchen@gmail.com> posted:
>On 2010-10-08 02:31 PM, Dr J R Stockton wrote:
>> In comp.lang.javascript message<i8jibh$n3o$1@news.eternal-
>> september.org>, Wed, 6 Oct 2010 21:29:41, Garrett Smith
>> <dhtmlkitchen@gmail.com> posted:
>>
>>> On 2010-10-06 12:45 PM, Dr J R Stockton wrote:
>>>> In comp.lang.javascript message<i8ejis$hf4$1@news.eternal-
>>>> september.org>, Tue, 5 Oct 2010 00:19:55, Garrett Smith
>>>> <dhtmlkitchen@gmail.com> posted:
>>>>
>>>>> FAQ Updated
>>
>> Section 6.3
>>>> Lacks mention of leading sign and/or whitespace.
>>>>
>>>
>>> Correct.
>>
>> Without such a mention, the entry is incorrect.
>I recall proposing the idea but it either got a tepid response or
>criticism. In the source comment, I have:
>
> If base 10 is desired,
> the unary <ICODE>+</ICODE> operator can be an option. Example:
>
>var s = '-09.1'; // Input string.
>var j = +s; // Convert to number. Result: -9.1
>var n = j|0; // Chop off decimal (convert ToInt32). Result: -9
>
>Anyway, conversion to number is covered in "why does 1 + 1 equal 11?"
>and more in-depth in the notes article.
Not the point. The description of parseInt is WRONG. Discussion of
unary + elsewhere is quite irrelevant to the omission of considering
leading space and/or sign in parseInt.
See <http://www.merlyn.demon.co.uk/js-faq-u.htm#WNR>.
Sections 6.3 & 6.4 are probably better as 6.4 & 6.3.
>>>> Does not acknowledge ECMA 262 5th Edn, Annex E, 15.1.2.2.
>>>
>>> Doesn't mention Ed 3 either.
>>
>> 3rd Edn lacks an Annex E.
>>
>
>That it does, however, although edition 3 permitted octal
>interpretation, it recommended implementations against doing that.
>
>And I see DevMo page for parseInt has not been updated for ES5.
><https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/parseInt>
>
>> 5th Edn requires "09" to convert to +9.
>>
>
>Now it is required.
>
>> All my current browsers convert "09" to 0 (I presume +0), though for a
>> while Opera gave +9.
>>
>That's odd. Opera took the ES3 recommendation but now that ES5 is out,
>Opera violates that.
Obviously ECMA chose to call for what is theoretically desirable, but
unacceptable in the light of past practice. No browser-writer will make
that change if not assured that, after the change, his browser will
definitely be in the majority. Microsoft used to be able to do that.
>> The FAQ should point out that while at present browsers give zero, there
>> must be a risk that they will become ECMA-compliant.
>
>That is a very strange way of looking at it.
>>>> Section 6.4 :
>>>> "Since plus (+) is also used as in string concatenation, '1' + 1 is
>>>> equal to '11'." is (or contains) a /non sequitur/.
>>>>
>>>
>>> How so?
>>
>> Well, assuming that you know what /non sequitur/ means, it should be
>> obvious. The truth of the portion of the sentence before the comma does
>> not *necessitate* the truth of the portion of the sentence after the
>> comma. It would have been possible to define + as addition, except only
>> when both sides are strings. Therefore, there should be no actual or
>> implied "since".
>>
>
>The + operator performs concatenation if either operand is a string,
>thus `'1' + 1` results "11".
I think I prefer "at least one" to "either", and "results" should be
"gives".
>> Should be "Because plus (+) concatenates if one or both operands of the
>> binary plus operator is a string, '1' + 1 gives '11'." with maybe "plus
>> adds if both operands are numbers".
>>
>But that's incomplete.
However, it is correct. To cover all cases, one needs to check
(assuming that A+B==B+A) at least 6 types of Object plus 6 types of
object, 21 tests, in several browsers and both currently-used versions
of ECMA (3 & 5).
>true + true == 2;
>1 + {valueOf:function(){return 1}} == 2;
>
>yet 1 + new Date is a string. I d
And most people will not get in all browsers what they expect from
new Date + " " + new Date() .
--
(c) John Stockton, nr London UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME.
Web <http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, and links.
Proper <= 4-line sig. separator as above, a line exactly "-- " (RFCs 5536/7)
Do not Mail News to me. Before a reply, quote with ">" or "> " (RFCs 5536/7)
|
|
0
|
|
|
|
Reply
|
Dr
|
10/10/2010 6:05:18 PM
|
|
|
5 Replies
129 Views
(page loaded in 0.112 seconds)
|