Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #9243
| From | "Aaron Sawyer" <aaron.sawyer@deltaware.com> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: JavaScript: Trouble with switch Syntax |
| Date | 2011-12-14 18:58 -0400 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <jcb9ni$s8l$1@speranza.aioe.org> (permalink) |
| References | <ug4ie75gitc6gc9rsse94i0slcpumt1pg0@4ax.com> |
"Gene Wirchenko" <genew@ocis.net> wrote in message news:ug4ie75gitc6gc9rsse94i0slcpumt1pg0@4ax.com... > Dear JavaScripters: > > I have hanged myself yet again with syntax. > > Did you know that -- in IE9, at least -- you can use > otherwise > instead of > default: > in a switch statement? > > Yes, you can. It does not throw an error, but it also does not > do anything. Unless you count time wasted looking for a bug. > > I may as well ask if anyone else has committed such bogosities. > Not that particular one, but plenty of others. 'otherwise' (without the quotes) on a line by itself, presumably following a 'break;'will trigger Javascript/JScript/ECMAscript's default behaviors: (1) 'otherwise' is not a reserved word, therefore it is an identifier; (2) the identifier 'otherwise' is not declared locally (in a 'var' statement), therefore it must be a property attached to the global object (and created there if not found); (3) end of line has been encountered, therefore a semicolon must have been intended (!) and will be supplied by the language processor. That 'otherwise' has successfully instantiated a property on the global object with initial value 'undefined', which is consumed in place by the semicolon (basically, it is an expression whose value is ignored). Not a problem! If it had been the case that 'otherwise' had a colon following it (otherwise:), then that would have been a statement label; again, no problem at all! Such a nice language processor, so eager to please! The syntax of Javascript draws heavily from the C language (not Pascal). I use Firefox a lot, and I have found the Mozilla Developer Network website particularly helpful: https://developer.mozilla.org/en/JavaScript/Reference For JScript, the Microsoft Developer Network is a good start point: http://msdn.microsoft.com/en-us/library/yek4tbz0%28v=VS.85%29.aspx and W3C gets me pointed at DOM/XML/XSL : http://www.w3.org/standards/ I also spent time looking at http://www.jslint.com/ <<--!! very useful !! http://javascript.crockford.com/ http://helephant.com/2008/08/17/how-javascript-objects-work/ http://jibbering.com/faq/notes/closures/ http://bonsaiden.github.com/JavaScript-Garden/ c.l.j contributors John Harris and John Stockton also have online resources available. There are doubtless others as well, and I intend no slight by my lack of knowledge. Learn and grow, share and enjoy!
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
JavaScript: Trouble with switch Syntax Gene Wirchenko <genew@ocis.net> - 2011-12-14 13:23 -0800
Re: JavaScript: Trouble with switch Syntax Jake Jarvis <pig_in_shoes@yahoo.com> - 2011-12-14 23:32 +0100
Re: JavaScript: Trouble with switch Syntax Tim Streater <timstreater@greenbee.net> - 2011-12-14 22:39 +0000
Re: JavaScript: Trouble with switch Syntax Gene Wirchenko <genew@ocis.net> - 2011-12-14 18:11 -0800
Re: JavaScript: Trouble with switch Syntax Dr J R Stockton <reply1150@merlyn.demon.co.uk> - 2011-12-16 21:28 +0000
Re: JavaScript: Trouble with switch Syntax "Aaron Sawyer" <aaron.sawyer@deltaware.com> - 2011-12-14 18:58 -0400
Re: JavaScript: Trouble with switch Syntax Jake Jarvis <pig_in_shoes@yahoo.com> - 2011-12-15 00:42 +0100
Re: JavaScript: Trouble with switch Syntax Jake Jarvis <pig_in_shoes@yahoo.com> - 2011-12-15 01:06 +0100
Re: JavaScript: Trouble with switch Syntax Gene Wirchenko <genew@ocis.net> - 2011-12-14 18:09 -0800
Re: JavaScript: Trouble with switch Syntax Ross McKay <au.org.zeta.at.rosko@invalid.invalid> - 2011-12-15 18:33 +1100
csiph-web