What are the key differences between JavaScript and ActionScript 3?

Todd Moses picture Todd Moses · Feb 15, 2010 · Viewed 35.7k times · Source

I know both languages are from the same ECMA-262 standard. It seems that the two are becoming very similar with JavaScript adding event listeners for core Object instances through methods like freeze and seal in EMCAScript-262 5th edition and such. I was wondering what the differences are?

Answer

Joa Ebert picture Joa Ebert · Feb 15, 2010

First of all ActionScript 3 and JavaScript are both defined in ECMA-262 so they have a lot in common. Both languages feature prototype inheritance for instance. It is however not correct that ActionScript fully implements ES4.

ActionScript implements a couple of features that are not defined in ECMA-262 and some -- but definitely not all -- of ES4.

So what does AS3 add to ECMA-262? Those are also the differences to JavaScript:

  • Dynamically and statically typed code
  • Packages, Classes and Interfaces
  • Standard OO inheritance model (not prototype based, statically typed)
  • uint and int datatype
  • E4X (ECMA-357)
  • Type-safe conditional compilation (ES4)
  • Vector.<T> datatype (ES4)

Maybe I have forgotten some features. I am not sure if XML, XMLList etc. are already defined in 262 or came with 357.

The key difference however is the standard library. JavaScript comes with a couple of predefined classes like DOMElement and browser dependent additions. ActionScript has a fairly large standard library with features like video streaming and is consistent over all platforms.