JavaScript Tips

  • Revision slug: Talk:JavaScript_Tips
  • Revision title: JavaScript Tips
  • Revision id: 172041
  • Created:
  • Creator: Np
  • Is current revision? No
  • Comment /* Moving from KB */

Revision Content

  • "The character set for XUL, DTD, script, and properties files is UTF-8 which is not easily readable."
    • This needs explanation. "Not easily readable" sounds weird. How is DTD being UTF-8 related to \uXXXX escapes?
  • "Convenience constants for interface names should be prefixed with nsI"
    • This makes little sense for mozI interfaces. Are the short names like nsIWBP a good idea anyway?
  • "Duplicate variable declaration"
    • This is not a JS strict warning anymore (iirc ben lobbied for that, need to find a bug and update the text in the article)

--Nickolay 14:30, 9 June 2006 (PDT)

Moving from KB

I'm looking into moving the info from this KB article here. There are two things that page has that this doesn't, and I'm not sure whether these are actual guidelines in use.

  • Private members should start with _
  • Unique prefixes or enclosing functions with a uniquely-named object (more important to extension developers?)

--Np 15:51, 31 August 2006 (PDT)

As far as I can see, people are following the first rule in general, and we should mention the unique name rule, although you're right, it's mostly for extension developers and may even belong on a page of its own, linked from this page. --Nickolay 09:51, 3 September 2006 (PDT)
I've added the unique name thing, saying its for people working in overlays rather than extension developers.--Np 14:33, 22 May 2007 (PDT)

Revision Source

<ul><li> "The character set for XUL, DTD, script, and properties files is UTF-8 which is not easily readable."
<ul><li> This needs explanation. "Not easily readable" sounds weird. How is DTD being UTF-8 related to \uXXXX escapes?
</li></ul>
</li><li> "Convenience constants for interface names should be prefixed with nsI"
<ul><li> This makes little sense for mozI interfaces. Are the short names like nsIWBP a good idea anyway?
</li></ul>
</li><li> "Duplicate variable declaration"
<ul><li> This is not a JS strict warning anymore (iirc ben lobbied for that, need to find a bug and update the text in the article)
</li></ul>
</li></ul>
<p>--<a href="User:Nickolay">Nickolay</a> 14:30, 9 June 2006 (PDT)
</p>
<h3 name="Moving_from_KB">Moving from KB</h3>
<p>I'm looking into moving the info from <a class="external" href="http://kb.mozillazine.org/JavaScript_coding_guidelines">this KB article</a> here. There are two things that page has that this doesn't, and I'm not sure whether these are actual guidelines in use.
</p>
<ul><li> Private members should start with _
</li><li> Unique prefixes or enclosing functions with a uniquely-named object (more important to extension developers?)
</li></ul>
<p>--<a href="User:Np">Np</a> 15:51, 31 August 2006 (PDT)
</p>
<dl><dd> As far as I can see, people are following the first rule in general, and we should mention the unique name rule, although you're right, it's mostly for extension developers and may even belong on a page of its own, linked from this page. --<a href="User:Nickolay">Nickolay</a> 09:51, 3 September 2006 (PDT)
</dd><dd> I've added the unique name thing, saying its for people working in overlays rather than extension developers.--<a href="User:Np">Np</a> 14:33, 22 May 2007 (PDT)
</dd></dl>
Revert to this revision