Quantcast
Channel: ClearScript
Viewing all articles
Browse latest Browse all 2297

New Post: Is it possible to validate script syntax before executing it?

$
0
0
Hi Tomaso,

hoMethod3("Three"); // the "dot" is missing - real syntax error

There's no syntax error here; this line simply invokes a function named "hoMethod3". If no such function exists when the line is executed, the script engine generates a runtime error. It may be semantically incorrect, but this line is 100% legal JavaScript, and because JavaScript has no static typing, the engine can't detect this kind of error prior to execution.

Does it recognize that Method34 doesn't exist before starting the execution or when the 3-rd line is processed??

As in the first example, the line is legal JavaScript, so the error would not be detected until runtime.

Cheers!

Viewing all articles
Browse latest Browse all 2297

Trending Articles