Finding Analysis Errors in Javascript

Is there an easy way to find parsing errors in javascript code?

Last week, I debugged a javascript problem when the first javascript function that was called gave the "expected object" error. Later, I decided that this was because the browser was unable to parse the javascript code. In the end, I solved the problem, but it was a painful process that included my code line by line, trying to find my error.

There should be an easier way.

+3
source share
3 answers

Use a tool like Jslint or an alternative browser.

IE , . ) , , ) , .

" " IE Opera. IE, .

:

var foo = {
  prop1 : 'value',
  prop2 : 'value',
  prop2 : 'value',   // <-- the problem
};

: IE6 IE7 , IE . , . , ( ) . Firefox Safari . Opera , ( ).

JavaScript - Firefox + Firebug. IE Opera , , .

+3

? IE8 javascript, Firefox, Firebug .

+3
  • , , , .

  • Safari 4 (which runs on both Mac OS X and Windows) comes with some development tools (including a debugger) that are very useful. If you prefer to use Firefox, Firebug provides similar functionality.

  • JSLint can help you track simple errors.

Steve

+1
source

Source: https://habr.com/ru/post/1709929/


All Articles