Reference

  • Revision slug: Talk:JavaScript/Reference
  • Revision title: Reference
  • Revision id: 189496
  • Created:
  • Creator: Dria
  • Is current revision? No
  • Comment

Revision Content

JS 1.2 and Gecko 1.8

Per the fix for bug 255895, "JavaScript1.2" values for the script's language attribute no longer work, e.g. <script language="JavaScript1.2"> will execute the script in the latest JS version rather than JS 1.2.

So how should this be documented? In Fx 1.0, JS 1.2 is available, but not in the upcoming Fx 1.5. There are 5 cases where "JavaScript1.2" is mentioned in this reference: Special:Search?search=JavaScript1.2&go=Go. How should they be revised?

--Maian 23:43, 21 September 2005 (PDT)

I think we need a new section in the reference that specifies the differences between versions, collecting this information into a single location rather than leaving it scattered haphazardly throughout the reference as it currently is. Once that is done, the various code samples should be updated to reflect current practices and code if they cannot be written in a "version-neutral" manner. Do you think this makes sense? -- dria 04:27, 22 September 2005 (PDT)
Those examples are not "bad examples" per se. They are there specifically to show the differences between the two versions. I was wondering what should be done about those examples, since they would no longer be valid with Fx 1.5+ and family. BTW, https://bugzilla.mozilla.org/attachment.cgi?id=195375 is a screenshot of a table of differences. --Maian 05:10, 22 September 2005 (PDT)
If the examples are there specifically to show the differences between two versions of JS, and if we have a section in the reference that is dedicated to discussing these differences, I would think that those samples should be included in that section of the reference. Or am I misunderstanding something? -- dria 05:30, 22 September 2005 (PDT)

Section title capitalization

There's an inconsistency in the capitalization of section titles. Some capitalize everything as if it's a book title. Others just capitalize the first word. Which scheme should we take, or does it even matter? --Maian 07:11, 8 September 2005 (PDT)

If you want to make them consistent, I think we should go with the "First word only" capitalization, rather than the book-title style. Thanks :) -- dria

deprecated pre box

Is there any wiki markup available for deprecated examples?

--Maian 20:24, 25 Aug 2005 (PDT)

Help:Custom_Templates#Template:deprecated_header --Nickolay 00:58, 26 Aug 2005 (PDT)
Hmm, that was a bad question. What I meant to ask is: what markup should I use for bad examples (which aren't necessarily deprecated), i.e. examples that show what not to do? --Maian 02:07, 26 Aug 2005 (PDT)
Oh, I don't think so, but you can ask dria to create a CSS class for that. --Nickolay 11:50, 26 Aug 2005 (PDT)
I'll add it to my TODO list for the new skins. I have to go through them again this weekend to fix up some stuff anyhow. Good idea, Maian. Thanks :) -- dria 21:06, 26 Aug 2005 (PDT)

coding style

Should semicolons be added to all the examples?

--Maian 21:06, 25 Aug 2005 (PDT)

The original authors didn't use semicolons, but I'd add them. --Nickolay 00:58, 26 Aug 2005 (PDT)

More coding style questions:

  • How many spaces should an indent have?
  • String literals in single or double quotes?
  • Code braces appear where?
if (x) {
} else {
}

or

if (x) {
}
else {
}

or

if (x)
{
}
else
{
}
  • What about empty code blocks?
if (x) {
}

or

if (x) {}
  • Should there be a space between operators and parenthesis?
if (x)
if(x)

Or does any of this matter?

--Maian 04:06, 31 Aug 2005 (PDT)

I'd say, just make a note here about decisions you make. It would be best to have all examples to use the same style. --Nickolay 05:37, 31 Aug 2005 (PDT)
Gonna follow Mozilla's coding guides here: http://www.mozilla.org/hacking/mozilla-style-guide.html#Visual --Maian 00:30, 20 September 2005 (PDT)
Oops, I wasn't styling function definitions and switch statements correctly... Oh well. --Maian 23:42, 21 September 2005 (PDT)

Revision Source

<h3 name="JS_1.2_and_Gecko_1.8"> JS 1.2 and Gecko 1.8 </h3>
<p>Per the fix for <a class="external" href="https://bugzilla.mozilla.org/show_bug.cgi?id=255895">bug 255895</a>, "JavaScript1.2" values for the script's language attribute no longer work, e.g. <code>&lt;script language="JavaScript1.2"&gt;</code> will execute the script in the latest JS version rather than JS 1.2.
</p><p>So how should this be documented? In Fx 1.0, JS 1.2 is available, but not in the upcoming Fx 1.5. There are 5 cases where "JavaScript1.2" is mentioned in this reference: <a href="Special:Search?search=JavaScript1.2&amp;go=Go">Special:Search?search=JavaScript1.2&amp;go=Go</a>. How should they be revised?
</p><p>--<a href="User:Maian">Maian</a> 23:43, 21 September 2005 (PDT)
</p>
<dl><dd> I think we need a new section in the reference that specifies the differences between versions, collecting this information into a single location rather than leaving it scattered haphazardly throughout the reference as it currently is.  Once that is done, the various code samples should be updated to reflect current practices and code if they cannot be written in a "version-neutral" manner. Do you think this makes sense? -- <a href="User:Dria">dria</a> 04:27, 22 September 2005 (PDT)
</dd></dl>
<dl><dd><dl><dd> Those examples are not "bad examples" per se. They are there specifically to show the differences between the two versions. I was wondering what should be done about those examples, since they would no longer be valid with Fx 1.5+ and family. BTW, https://bugzilla.mozilla.org/attachment.cgi?id=195375 is a screenshot of a table of differences. --<a href="User:Maian">Maian</a> 05:10, 22 September 2005 (PDT)
</dd></dl>
</dd></dl>
<dl><dd><dl><dd><dl><dd> If the examples are there specifically to show the differences between two versions of JS, and if we have a section in the reference that is dedicated to discussing these differences, I would think that those samples should be included in that section of the reference.  Or am I misunderstanding something? -- <a href="User:Dria">dria</a> 05:30, 22 September 2005 (PDT)
</dd></dl>
</dd></dl>
</dd></dl>
<h3 name="Section_title_capitalization"> Section title capitalization </h3>
<p>There's an inconsistency in the capitalization of section titles. Some capitalize everything as if it's a book title. Others just capitalize the first word. Which scheme should we take, or does it even matter? --<a href="User:Maian">Maian</a> 07:11, 8 September 2005 (PDT)
</p>
<dl><dd> If you want to make them consistent, I think we should go with the "First word only" capitalization, rather than the book-title style.  Thanks :) -- <a href="User:Dria">dria</a>
</dd></dl>
<h3 name="deprecated_pre_box"> deprecated pre box </h3>
<p>Is there any wiki markup available for deprecated examples?
</p><p>--<a href="User:Maian">Maian</a> 20:24, 25 Aug 2005 (PDT)
</p>
<dl><dd> <a href="Help:en/Custom_Templates#Template:deprecated_header">Help:Custom_Templates#Template:deprecated_header</a> --<a href="User:Nickolay">Nickolay</a> 00:58, 26 Aug 2005 (PDT)
</dd></dl>
<dl><dd><dl><dd> Hmm, that was a bad question.  What I meant to ask is: what markup should I use for <i>bad</i> examples (which aren't necessarily deprecated), i.e. examples that show what not to do? --<a href="User:Maian">Maian</a> 02:07, 26 Aug 2005 (PDT)
</dd></dl>
</dd></dl>
<dl><dd><dl><dd><dl><dd> Oh, I don't think so, but you can ask dria to create a CSS class for that. --<a href="User:Nickolay">Nickolay</a> 11:50, 26 Aug 2005 (PDT)
</dd></dl>
</dd></dl>
</dd></dl>
<dl><dd><dl><dd><dl><dd><dl><dd> I'll add it to my TODO list for the new skins.  I have to go through them again this weekend to fix up some stuff anyhow.  Good idea, Maian.  Thanks :) -- <a href="User:Dria">dria</a> 21:06, 26 Aug 2005 (PDT)
</dd></dl>
</dd></dl>
</dd></dl>
</dd></dl>
<h3 name="coding_style"> coding style </h3>
<p>Should semicolons be added to all the examples?
</p><p>--<a href="User:Maian">Maian</a> 21:06, 25 Aug 2005 (PDT)
</p>
<dl><dd> The original authors didn't use semicolons, but I'd add them. --<a href="User:Nickolay">Nickolay</a> 00:58, 26 Aug 2005 (PDT)
</dd></dl>
<p>More coding style questions:
</p>
<ul><li> How many spaces should an indent have?
</li></ul>
<ul><li> String literals in single or double quotes?
</li></ul>
<ul><li> Code braces appear where?
</li></ul>
<pre>if (x) {
} else {
}
</pre>
<p>or
</p>
<pre>if (x) {
}
else {
}
</pre>
<p>or
</p>
<pre>if (x)
{
}
else
{
}
</pre>
<ul><li> What about empty code blocks?
</li></ul>
<pre>if (x) {
}
</pre>
<p>or
</p>
<pre>if (x) {}
</pre>
<ul><li> Should there be a space between operators and parenthesis?
</li></ul>
<pre>if (x)
</pre>
<pre>if(x)
</pre>
<p>Or does any of this matter?
</p><p>--<a href="User:Maian">Maian</a> 04:06, 31 Aug 2005 (PDT)
</p>
<dl><dd> I'd say, just make a note here about decisions you make. It would be best to have all examples to use the same style. --<a href="User:Nickolay">Nickolay</a> 05:37, 31 Aug 2005 (PDT)
</dd></dl>
<dl><dd><dl><dd> Gonna follow Mozilla's coding guides here: http://www.mozilla.org/hacking/mozilla-style-guide.html#Visual --<a href="User:Maian">Maian</a> 00:30, 20 September 2005 (PDT)
</dd></dl>
</dd></dl>
<dl><dd><dl><dd><dl><dd> Oops, I wasn't styling function definitions and switch statements correctly... Oh well. --<a href="User:Maian">Maian</a> 23:42, 21 September 2005 (PDT)
</dd></dl>
</dd></dl>
</dd></dl>
Revert to this revision