Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #8700
| Message-ID | <3004275.SPkdTlGXAF@PointedEars.de> (permalink) |
|---|---|
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
| Organization | PointedEars Software (PES) |
| Date | 2011-11-29 13:28 +0100 |
| Subject | Re: Declarations (esp. of Globals) |
| Newsgroups | comp.lang.javascript |
| References | <78g8d712uedb7c0ugjgpdrkeg8lnugta14@4ax.com> <Xns9FABE6915254Ainvalidcom@94.75.214.39> |
| Followup-To | comp.lang.javascript |
Followups directed to: comp.lang.javascript
Mike Duffy wrote: > Gene Wirchenko <genew@ocis.net> wrote […]: >> I am a stickler for declarations and prefer to declare >> everything. As applied to JavaScript, what say you? And why? > > I agree 100%. In the case of Javascript, even more so. There is no "Javascript" [1]. However, in ECMAScript implementations like JavaScript, JScript, etc., variable declarations are important: If you do not declare an identifier a variable, and assign to it, one of three things can happen: nothing (no effect at all, because an existing property was read-only), an exception is thrown (because an existing property could not be overwritten or created), or a property of the global object is being created or overwritten (sometimes called an "implied global"). With a variable declaration, the scope of a standalone identifier is clear. That is why in ECMAScript Edition 5.x's Strict Mode¹, such an assignment, if the identifier cannot be resolved, always throws a ReferenceError exception. You can attempt to trigger Strict Mode with "use strict"; on top of the code or function body. See also: <https://developer.mozilla.org/en/JavaScript/Strict_mode> PointedEars ___________ ¹ not to be confused with layout engines' Standards (Compliance) Mode [1] <http://PointedEars.de/es-matrix> -- Prototype.js was written by people who don't know javascript for people who don't know javascript. People who don't know javascript are not the best source of advice on designing systems that use javascript. -- Richard Cornford, cljs, <f806at$ail$1$8300dec7@news.demon.co.uk
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Declarations (esp. of Globals) Gene Wirchenko <genew@ocis.net> - 2011-11-28 18:25 -0800
Re: Declarations (esp. of Globals) Mike Duffy <Use_guestbook_page@website.in.sig> - 2011-11-29 03:39 +0000
Re: Declarations (esp. of Globals) Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-11-29 13:28 +0100
Re: Declarations (esp. of Globals) John G Harris <john@nospam.demon.co.uk> - 2011-11-29 15:39 +0000
Re: Declarations (esp. of Globals) Gene Wirchenko <genew@ocis.net> - 2011-11-29 12:17 -0800
Re: Declarations (esp. of Globals) Mike Duffy <Use_guestbook_page@website.in.sig> - 2011-11-29 20:43 +0000
Re: Declarations (esp. of Globals) Gene Wirchenko <genew@ocis.net> - 2011-11-29 13:48 -0800
Re: Declarations (esp. of Globals) Mike Duffy <Use_guestbook_page@website.in.sig> - 2011-11-29 22:11 +0000
Re: Declarations (esp. of Globals) Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-11-29 23:52 +0100
Re: Declarations (esp. of Globals) Gene Wirchenko <genew@ocis.net> - 2011-11-29 15:11 -0800
Re: Declarations (esp. of Globals) Scott Sauyet <scott.sauyet@gmail.com> - 2011-11-30 04:31 -0800
Re: Declarations (esp. of Globals) Gene Wirchenko <genew@ocis.net> - 2011-11-30 14:18 -0800
Re: Declarations (esp. of Globals) Scott Sauyet <scott.sauyet@gmail.com> - 2011-12-01 06:31 -0800
Re: Declarations (esp. of Globals) "Tom de Neef" <tdeneef@qolor.nl> - 2011-12-01 11:34 +0100
Re: Declarations (esp. of Globals) Gene Wirchenko <genew@ocis.net> - 2011-12-01 11:57 -0800
Re: Declarations (esp. of Globals) Scott Sauyet <scott.sauyet@gmail.com> - 2011-11-29 13:36 -0800
Re: Declarations (esp. of Globals) Gene Wirchenko <genew@ocis.net> - 2011-11-29 15:13 -0800
Re: Declarations (esp. of Globals) John G Harris <john@nospam.demon.co.uk> - 2011-11-30 17:03 +0000
Re: Declarations (esp. of Globals) Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-11-29 23:42 +0100
csiph-web