473,396 Members | 2,111 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

why JavaScript can't be smarter when throwing you an error message

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

Feb 28 '07 #1
4 1484
ja********@gmail.com said the following on 2/27/2007 9:24 PM:
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
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>

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Feb 28 '07 #2
On Feb 28, 2:24 am, "jackcha...@gmail.com" wrote:
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
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.

Feb 28 '07 #3
On Wed, 28 Feb 2007 02:45:06 -0800, Richard Cornford wrote:
On Feb 28, 2:24 am, "jackcha...@gmail.com" wrote:
>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

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.
Feb 28 '07 #4
In comp.lang.javascript message <11**********************@a75g2000cwd.go
oglegroups.com>, Tue, 27 Feb 2007 18:24:49, "ja********@gmail.com"
<ja********@gmail.composted:
>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.

--
(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.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
Feb 28 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

41
by: Mr. x | last post by:
Hello, Can I make my java script code be invisible to other people who enter into my site by IE browser ? - How ? Thanks :)
7
by: Fendi Baba | last post by:
The function is called from opencalendar(targetfield). Thanks for any hints on what could be the problem. .............................................................. var...
6
by: Chris | last post by:
Can anyone point me to some code that will display messages, in a seperate window, from javascipt. ie effectively a trace window? TIA Chris
12
by: Jeff S | last post by:
In a VB.NET code behind module, I build a string for a link that points to a JavaScript function. The two lines of code below show what is relevant. PopupLink = "javascript:PopUpWindow(" &...
2
by: Jake Barnes | last post by:
Using javascript closures to create singletons to ensure the survival of a reference to an HTML block when removeChild() may remove the last reference to the block and thus destory the block is...
3
by: Prash | last post by:
IIS serving javascript files, gives me error 4/21/2006 6:48 AM Guys/Gals, I am using IIS as a server to serve the javascript files. But it is giving me the error as "Object doesn't support this...
4
by: jehugaleahsa | last post by:
Hello: I am going through an effort to standardize web applications for my company. We are trying to figure out the best practices for security, error handling, etc. I've just done a large...
24
by: Aaron Gray | last post by:
From what I have been looking at for Javascript library development, browsers that support Javascript 1.5/ECMAScript 3/JScript 5.5 looks like the base level to pitch at. Anyone add anything ? ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.