Javascript
Javascript
JavaScript is a cross-platform, object-oriented scripting language. JavaScript is a small, lightweight language; it is not useful as a standalone language, but is designed for easy embedding in other products and applications, such as web browsers. Inside a host environment, JavaScript can be connected to the objects of its environment to provide programmatic control over them.
Limitations
- JavaScript has a concept of objects and classes but no built-in concept of inheritance.
- Javascript only has a few built-in types (boolean, float, string, object, array) and it converts from one to another quite freely.
- JavaScript objects (some call them associative arrays) are like maps in a O-O style with map keys of type String.
- Use the following to find out whether a JavaScript object supports a certain property or function:
if (typeof (myObj,someProperty) != undefined) { ... } if (myObj instanceof MyObj) { ... }
Note: The instance instantiated from JSON is always of type Object Array, therefore it does not work well with the "instanceof" operator.
JavaScript Utilities
There are many tools that can assist Javascript development.
Debugging
- DOM Inspector (built into Mozilla, need to grab IE plugins) - To observe the current state of the page
- Venkman or Microsoft Script Debugger - to troubleshoot behaviorial problems
- Ajax Debugging Tool (http://blog.monstuff.com/archives/000252.html)
- IE Leak Detector (http://blog.monstuff.com/archives/000252.html)
- JavaScript console in your browser - To check for errors
Unit Testing
- JsUnit (http://sourceforge.net/projects/jsunit)
- Selenium (http://selenium.thoughtworks.com)