Within JavaScript, access to a debugger becomes invaluable when developing large, non-trivial programs. Because there can be implementation differences between the various browsers (particularly within the Document Object Model), it is useful to have access to a debugger for each of the browsers that a web application targets.
Script debuggers are available for Internet Explorer, Firefox, Safari, Google Chrome, Opera and Node.js
Three debuggers are available for Internet Explorer: Microsoft Visual Studio is the richest of the three, closely followed by Microsoft Script Editor (a component of Microsoft Office), and finally the free Microsoft Script Debugger which is far more basic than the other two. The free Microsoft Visual Web Developer Express provides a limited version of the JavaScript debugging functionality in Microsoft Visual Studio. Internet Explorer has included developer tools since version 8 (reached by pressing the F12 key).
Web applications within Firefox can be debugged using the Firebug add-on, or the older Venkman debugger. Firefox also has a simpler built-in Error Console, which logs and evaluates JavaScript. It also logs CSS errors and warnings.
Opera includes a set of tools called Dragonfly.
Web Kit's Web Inspector includes a JavaScript debugger, which is used in Safari. A modified version called Blink Dev Tools is used in Google Chrome.
Node.js has node-inspector, an interactive debugger that integrates with the Blink Dev Tools, available in Google Chrome.
Some debugging aids are themselves written in JavaScript and built to run on the Web. An example is the program JSLint, developed by Douglas Crock ford who has written extensively on the language. JS Lint scans JavaScript code for conformance to a set of standards and guidelines.
Version History.
The following table is based on information from multiple sources.
Version | Release date | Equivalent to | Netscape Navigator | Mozilla Firefox | Internet Explorer | Opera | Safari | Google Chrome |
---|---|---|---|---|---|---|---|---|
1.0 | March 1996 | 2.0 | 3.0 | |||||
1.1 | August 1996 | 3.0 | ||||||
1.2 | June 1997 | 4.0-4.05 | 3 | |||||
1.3 | October 1998 | ECMA-262 1st + 2nd edition | 4.06-4.7x | 4.0 | 5 | |||
1.4 | Netscape Server | 6 | ||||||
1.5 | November 2000 | ECMA-262 3rd edition | 6.0 | 1.0 | 5.5 (JScript 5.5), 6 (JScript 5.6), 7 (JScript 5.7), 8 (JScript 5.8) | 7.0 | 3.0-5 | 1.0-10.0.666 |
1.6 | November 2005 | 1.5 + array extras + array and string generics + E4X | 1.5 | |||||
1.7 | October 2006 | 1.6 + Pythonic generators + iterators + let | 2.0 | 28.0.1500.95 | ||||
1.8 | June 2008 | 1.7 + generator expressions + expression closures | 3.0 | 11.50 | ||||
1.8.1 | 1.8 + native JSON support + minor updates | 3.5 | ||||||
1.8.2 | June 22, 2009 | 1.8.1 + minor updates | 3.6 | |||||
1.8.5 | July 27, 2010 | 1.8.2 + ECMAScript 5 compliance | 4 | 9 | 11.60 | 6.00 |
Legend:
Old version
Latest version
Criticisms.
JavaScript is a loosely typed language (see Dynamic typing above). Loose typing places a majority responsibility for static type management on programmer discipline, very little on the compiler, and late reporting of type safety violation on the run-time. The result is a development environment where type bugs can be easily introduced due to human fallibility. The bugs may be difficult to detect or may go undetected by the run-time for several reasons:
- Bugs may never be detected due to host code never being exercised.
- Bugs may not be detected due to unreachable host code.
- Bugs may not be detected due to not meeting governing business rules, even though technically correctly typed.
Criticism based on loose typing then cautions programmers to be aware of the need for greater programmer discipline and project schedule impact because both detected and undetected bugs increase production time at unpredictable rates.
Related Languages And Features.
JSON, or JavaScript Object Notation, is a general-purpose data interchange format that is defined as a subset of JavaScript's literal syntax.
jQuery is a popular JavaScript library designed to simplify DOM-oriented client-side HTML scripting along with offering cross-browser compatibility because various browsers respond differently to certain vanilla JavaScript code.
Under score.js is a utility JavaScript library for data manipulation which is used in both client-side and server-side network applications.
Mozilla browsers currently support Live Connect, a feature that allows JavaScript and Java to intercommunicate on the web. However, Mozilla-specific support for Live Connect is scheduled to be phased out in the future in favor of passing on the Live Connect handling via NPAPI to the Java 1.6+ plug-in (not yet supported on the Mac as of March 2010). Most browser inspection tools, such as Firebug in Firefox, include JavaScript interpreters that can act on the visible page's DOM.
asm.js is a subset of JavaScript that can be run in any JavaScript engine or run faster in an ahead-of-time (AOT) compiling engine
Use As An Intermediate Language.
As JavaScript is the most widely supported client-side language that can run within a web browser, it has become an intermediate language for other languages to target. This has included both newly created languages and ports of existing languages. Some of these include:
- Objective-J, a super set of JavaScript that compiles to standard JavaScript. It adds traditional inheritance and Small talk /Objective-C style dynamic dispatch and optional pseudo-static typing to JavaScript.
- Processing.js, a JavaScript port of Processing, a programming language designed to write visualizations, images, and interactive content. It allows web browsers to display animations, visual applications, games and other graphical rich content without the need for a Java applet or Flash plugin.
- Coffee Script, an alternate syntax for JavaScript intended to be more concise and readable. It adds features like array comprehensions (also available in JavaScript since version 1.7) and pattern matching. Like Objective-J, it compiles to JavaScript. Ruby and Python have been cited as influential on Coffee Script syntax.
- Google Web Toolkit translates a subset of Java to JavaScript.
- Scala, an object-oriented and functional programming language, has an experimental Scala-to-Javascript compiler.
- Pyjamas, a port of Google Web Toolkit to Python (translates a subset of Python to JavaScript)
- Dart, an open-source programming language developed by Google, can be compiled to JavaScript.
- Whalesong, a Racket-to-JavaScript compiler.
- Emscripten, a LLVM-backend for porting native libraries to JavaScript.
- Fantom a programming language that runs on JVM, .NET and JavaScript.
- TypeScript, a free and open-source programming language developed by Microsoft. It is a super set of JavaScript, and essentially adds optional static typing and class-based object-oriented programming to the language.
- Haxe, an open-source high-level multi platform programming language and compiler that can produce applications and source code for many different platforms including JavaScript.
- Clojure Script, a compiler for Clojure that targets JavaScript. It is designed to emit JavaScript code which is compatible with the advanced compilation mode of the Google Closure optimizing compiler.
- Kotlin, a statically-typed language that also compiles to Java byte code.
JavaScript And Java.
A common misconception is that JavaScript is similar or closely related to Java. It is true that both have a C-like syntax (the C language being their most immediate common ancestor language). They also are both typically sand boxed (when used inside a browser), and JavaScript was designed with Java's syntax and standard library in mind. In particular, all Java keywords were reserved in original JavaScript, JavaScript's standard library follows Java's naming conventions, and JavaScript's Math and Date objects are based on classes from Java 1.0, but the similarities end there.The differences between the two languages are more prominent than their similarities. Java has static typing, while JavaScript's typing is dynamic. Java is loaded from compiled byte code, while JavaScript is loaded as human-readable source code. Java's objects are class-based, while JavaScript's are prototype-based. Finally, Java did not support functional programming until Java 8, while JavaScript does, as it contains many features based on Scheme.