[Javascript] semicolon insertion paranoia

m.j.milicevic list at machak.com
Thu May 18 20:34:12 CDT 2006


don't think so..
but why not use:
function invert(given) {return !given;}

and you have no worries..

kind regards,
-m.j.milicevic
http://www.machak.com

----- Original Message ----- 
From: "Steve Clay" <sclay at ufl.edu>
To: <javascript at LaTech.edu>
Sent: Friday, May 19, 2006 3:01 AM
Subject: [Javascript] semicolon insertion paranoia


>I know that it's poor practice to rely on automatic semicolon insertion at
> the end of lines, but I'm sometimes paranoid that, when I just want to use
> whitespace liberally, some JS engine out there is going to automatically
> insert a semicolon that breaks my statement.
> 
> Consider:
> 
> function invert(given) {
>  return given
>  ? false
>  : true;
> }
> 
> If "return given" was converted to "return given;", a syntax error would
> occur on the next line, or the function would completely change..
> 
> Do I need to worry about stuff like this? Would JS engines parse the
> following function /faster/?
> 
> function invert(given) {
>  return given ?
>    false
>  : true;
> }
> 
> Steve
> -- 
> http://mrclay.org/
> 
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript



More information about the Javascript mailing list