It took me a while to figure out this error
functiom method1(){ alert(); }
by this error message
missing ; before statement
functiom method1(){ alert(); }
why Javascript can't tell me directly
Randy Webb - 28 Feb 2007 05:13 GMT
jackchang1@gmail.com said the following on 2/27/2007 9:24 PM:
> It took me a while to figure out this error
>
[quoted text clipped - 6 lines]
>
> why Javascript can't tell me directly
Because Javascript isn't AI. How would it know whether you meant
function or functiom(); or were trying to create a variable followed by
a function call? If you want syntax checking, try JSLint:
<URL: http://www.jslint.com/lint.html>

Signature
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Richard Cornford - 28 Feb 2007 10:45 GMT
On Feb 28, 2:24 am, "jackcha...@gmail.com" wrote:
> It took me a while to figure out this error
>
[quoted text clipped - 6 lines]
>
> why Javascript can't tell me directly
Javascript did tell you directly, it just told you about its problem
not yours. Its problem is that - functiom - is a valid (but pointless)
Expression, and so a valid ExpressionStatement, and - method1() - is
also a valid Expression (a Call Expression, and so a valid
ExpressionStatement) and so also a valid expression statement, but if
you omit the optional semicolon form the end of the first
ExpressionStatement then javascript can only automatically insert it
for you if you put a line terminator before then following
ExpressionStatement. As there is no line terminator javascript is
expecting to see that semicolon, and when it is not seen it tells you
that it was expecting it, which seems reasonable.
If you want to avoid not noticing mis-typed keywords you should try
being smarter yourself and get yourself a syntax-highlighting editor
that colors javascript keywords distinctly differently from
Identifiers.
Richard.
Ivan Marsh - 28 Feb 2007 17:12 GMT
> On Feb 28, 2:24 am, "jackcha...@gmail.com" wrote:
>> It took me a while to figure out this error
[quoted text clipped - 10 lines]
> Javascript did tell you directly, it just told you about its problem not
> yours.
That's very eloquent.
I think the most difficult bugs to track down are the ones that aren't
logic related.
Like accidentally using = instead of ==, no debugger is ever going to
ask you if you meant equality not assignment.
Dr J R Stockton - 28 Feb 2007 16:22 GMT
In comp.lang.javascript message <1172629489.606763.214350@a75g2000cwd.go
oglegroups.com>, Tue, 27 Feb 2007 18:24:49, "jackchang1@gmail.com"
<jackchang1@gmail.com> posted:
>It took me a while to figure out this error
>
> functiom method1(){ alert(); }
Already explained. If there are some typoes that you make frequently
and/or find hard to see, you can process your pages with a suitable
search/ask/replace tool.
I have a batch file (try.bat; "try" is easy to type) which does various
checks (including with W3's TIDY) on any *.htm file changed since it was
last run. Part of it offers the following left-to-right word
substitutions : anf = and, ar = at, hoe = how, 8061 = 8601, wnen = when.
Of course, one then must avoid using those "words".
It's a good idea to read the newsgroup and its FAQ. See below.

Signature
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6
news:comp.lang.javascript FAQ <URL:http://www.jibbering.com/faq/index.html>.
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.