Understanding the ActionScript Language > Differences between ActionScript and JavaScript |  |

Differences between ActionScript and JavaScript

ActionScript is similar to the core JavaScript programming language. You don't need to know JavaScript to use and learn ActionScript; however, if you know JavaScript, ActionScript will appear familiar to you.

This manual does not attempt to teach programming in general. There are many resources available that provide more information about general programming concepts and the JavaScript language.

| The European Computers Manufacturers Association (ECMA) document ECMA-262 is derived from JavaScript and serves as the international standard for the JavaScript language. ActionScript is based on the ECMA-262 specification.
| Netscape DevEdge Online has a JavaScript Developer Central site that contains documentation and articles useful for understanding ActionScript. The most valuable resource is the Core JavaScript Guide.

Some of the differences between ActionScript and JavaScript are as follows:

| ActionScript does not support browser-specific objects such as Document, Window, and Anchor.
| ActionScript does not completely support all of the JavaScript built-in objects.
| ActionScript supports syntax constructs that are not permitted in JavaScript (for example, the `tellTarget` and `ifFrameLoaded` actions and slash syntax). However, the use of these syntax constructs is not recommended; instead, use ActionScript elements that are like those in JavaScript (for example, `with`, `_framesloaded`, and dot syntax).
| ActionScript does not support some JavaScript syntax constructs, such as `try`, `catch`, `throw`, and statement labels.
| ActionScript does not support the JavaScript `Function` constructor.
| In ActionScript, the `eval` action can only perform variable references.
| In JavaScript, `toString` of `undefined` is `undefined`. In Flash 5 and Flash MX, for Flash 4 compatibility, `toString` of `undefined` is `""`.
| In JavaScript, evaluating `undefined` in a numeric context results in `NaN`. In Flash 5 and Flash MX, for Flash 4 compatibility, evaluating `undefined` results in 0.
| In JavaScript, when a string is evaluated in a Boolean context and the string has a nonzero length, the result is `true`; if the string doesn't have a nonzero length, the result is `false`. In ActionScript, the string is converted to a number. If the number is nonzero, the result is `true`; otherwise, the result is `false`.