You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 30 Next »

Legend for Javascript column color usage:

Black: JavaScript matches ActionScript

Red: solution not agreed upon

Blue: solution looks good, need consencus to approve (use Comments or Notes column)

Green: solution agreed upon

 

Test Available In FlexJS (+/-)?

ActionScript

JavaScript + Closure annotation

Notes

Global Constants

 

 

 

 

Infinity

-

Infinity

Infinity

 

-Infinity

-

-Infinity

-Infinity

 

NaN

-

NaN

NaN

 

undefined

-

undefined

undefined

 

 

 

 

 

 

Global Functions

 

 

 

 

Array()

-

Array(...values)

Array(...values)

 

Boolean()

-

Boolean(value)

Boolean(value)

 

decodeURI()

-

decodeURI(value)

decodeURI(value)

 

decodeURIComponent()

-

decodeURIComponent(value)

decodeURIComponent(value)

 

encodeURI()

-

encodeURI(value)

encodeURI(value)

 

encodeURIComponent()

-

encodeURIComponent(value)

encodeURIComponent(value)

 

escape()

-

escape(value)

escape(value)

 

int()

-

int(value)

int(value)

See "diff" page...

isFinite()

-

isFinite(value)

isFinite(value)

 

isNaN()

-

isNaN(value)

isNaN(value)

 

isXMLName()

-

isXMLName(value)

See "E4X" page...

 

Number()

-

Number(value)

Number(value)

 

Object()

-

Object(value)

Object(value)

 

parseFloat()

-

parseFloat(value)

parseFloat(value)

 

parseInt()

-

parseInt(value, [radix])

parseInt(value, [radix])

 

String()

-

String(value)

String(value)

 

trace()

-

trace(...values)

trace(...values)

See "diff" page...

uint()

 

uint(value)

uint(value)

See "diff" page...

unescape()

-

unescape(value)

unescape(value)

 

Vector()

-

result = Vector.<type>(valueArray);

See "diff" page...

 

XML()

-

XML(value)

See "E4X" page...

 

XMLList()

 

XMLList(value)

See "E4X" page...


 

 

 

 

 

Classes

 

 

 

 

ArgumentError

-

ArgumentError

ArgumentError

See "diff" page...

arguments

-

arguments

arguments

 

Array

-

Array

Array

See "diff" page...

Boolean

 

Boolean

Boolean

 

Class

-

-

-

See "Class" page...

Date

-

Date

Date

See "diff" page...

DefinitionError

-

DefinitionError

DefinitionError

See "diff" page...

Error

-

Error

Error

See "diff" page...

EvalError

-

EvalError

EvalError

See "diff" page...

Function

-

Function

Function

 

int

-

int

int

See "diff" page...

JSON

-

JSON

JSON

See "diff" page...

Math

-

Math

Math

 

Namespace

-

Namespace

Namespace

See "diff" page...

Number

-

Number

Number

 

Object

-

Object

Object

See "diff" page...

QName

-

QName

See "E4X" page...

 

RangeError

-

RangeError

RangeError

See "diff" page...

ReferenceError

-

ReferenceError

ReferenceError

See "diff" page...

RegExp

-

RegExp

RegExp

See "diff" page...

SecurityError

-

SecurityError

SecurityError

See "diff" page...

String

-

String

String

See "diff" page...

SyntaxError

-

SyntaxError

SyntaxError

See "diff" page...

TypeError

-

TypeError

TypeError

See "diff" page...

uint

-

uint

uint

See "diff" page...

URIError

-

URIError

URIError

See "diff" page...

Vector

-

Vector

See "diff" page...

 

VerifyError

-

VerifyError

VerifyError

See "diff" page...

XML

-

XML

See "E4X" page...

 

XMLList

-

XMLList

See "E4X" page...


 

 

 

 

 

Arithmetic

 

 

 

 

+

-

+

+

 

--

-

--

--

 

/

-

/

/

 

++

-

++

++

 

%

-

%

%

 

*

-

*

*

 

-

-

-

-

 

 

 

 

 

 

Arithmetic compound assignment

 

 

 

 

+=

-

+=

+=

 

/=

-

/=

/=

 

%=

-

%=

%=

 

*=

-

*=

*=

 

-=

-

-=

-=

 

 

 

 

 

 

Assignment

 

 

 

 

=

-

=

=

 

 

 

 

 

 

Bitwise

 

 

 

 

&

-

&

&

 

<<

-

<<

<<

 

~

-

~

~

 

|

-

|

|

 

>>

-

>>

>>

 

>>>

-

>>>

>>>

 

^

-

^

^

 

 

 

 

 

 

Bitwise compound assignment

 

 

 

 

&=

-

&=

&=

 

<<=

-

<<=

<<=

 

|=

-

|=

|=

 

>>=

-

>>=

>>=

 

>>>=

-

>>>=

>>>=

 

^=

-

^=

^=

 

 

 

 

 

 

Comment

 

 

 

 

/**/

-

/**/

/**/

 

//

-

//

//

 

 

 

 

 

 

Comparison

 

 

 

 

==

-

==

==

 

>

-

>

>

 

>=

-

>=

>=

 

!=

-

!=

!=

 

<

-

<

<

 

<=

-

<=

<=

 

===

-

===

===

 

!==

-

!==

!==

 

 

 

 

 

 

Logical

 

 

 

 

&&

-

&&

&&

 

&&=

-

x &&= y

x = x && y

Excellent suggestion from Fank: Keep It Simple, Stupid ;-)

!

-

!

!

 

||

-

||

||

 

||=

-

x ||= y

x = x || y

KISS, again.

 

 

 

 

 

Other

 

 

 

 

[]

-

[]

[]

 

as

-

as

?

I think we need a utility function

,

-

,

,

 

?:

-

(value) ? true : false;

(value) ? true : false;

 

delete

-

delete

delete

 

.

-

.

.

 

in

-

in

in

 

instanceof

-

instanceof

instanceof

We need to check the "goog" way of inheritance for correctness of the JS 'instanceof' and see if the Closure annotation method for implementing "Interfaces" covers the functionality of AS 'instanceof'.

is

-

is

?

I think we need a utility function

::

-

::

?

 

new

-

new

new

 

{}

-

{}

{}

 

()

-

()

()

 

/

-

/

/

Is the regular expression syntax the same between the two (AS and JS) implementations?

:

-

:

multiple solutions, context dependent

To "strongly" type JS, we use the Google Closure annotations. These are JSDoc block that go with function or variable declarations and give the Closure Compiler hints as to the type of variables, arguments and return values.

typeof

-

typeof

typeof

Only the "xml" type is not supported on the JS side (nor are the data types that go with it, XML and XMLList)

void

-

void

void

Note: this applies to 'void' as an operator, not the "data type"

 

 

 

 

 

String

 

 

 

 

+

-

+

+

 

+=

-

+=

+=

 

"

-

"

"

 

 

 

 

 

 

XML

 

 

 

 

@

-

@

See "E4X" page...


{}

-

{}

See "E4X" page...

This is the same as used in AS object literals, Mike: can you make the distinction?

[]

-

[]

See "E4X" page...

This isthe same as used in AS array literals, Mike: can you make the distinction?

+

-

+

See "E4X" page...

This isthe same as used the AS concatenation operator: Mike, can you make the distinction?

+=

-

+=

See "E4X" page...

This isthe same as used the AS concatenation operator: Mike, can you make the destinction?

delete

-

delete

See "E4X" page...

This is the same as used the AS delete operator: Mike, can you make the distinction?

..

-

..

See "E4X" page...


.

-

.

See "E4X" page...

This is the same as used the AS access operator: Mike, can you make the distinction?

()

-

()

See "E4X" page...

This is the same as used the AS grouping operator: Mike, can you make the destinction?

<>

-

<>

See "E4X" page...

 

 

 

 

 

 

Statements

 

 

 

 

break

-

break

break

 

case

-

case

case

 

continue

-

continue

continue

 

default

-

default

default

 

do...while

-

do...while

do...while

 

else

-

else

else

 

for

-

for

for

 

for...in

-

for...in

for...in

 

for each...in

-

for each...in

?

We need the compiler to rework the AS loop a bit... (See comment from Frank: https://cwiki.apache.org/confluence/display/FLEX/AS+to+JS+translation+table?focusedCommentId=30745636#comment-30745636).

if

-

if

if

 

label

-

label

label

 

return

-

return

return

 

super

-

super([arg1, ..., argN]);
super.method([arg1, ..., argN]);

goog.base(this, [arg1, ..., argN]);
goog.base(this, "method", [arg1, ..., argN]);

 

switch

-

switch

switch

 

throw

-

throw

throw

 

try...catch...finally

-

try...catch...finally

try...catch...finally

 

while

-

while

while

 

with

-

with

with

 

 

 

 

 

 

Attribute Keywords

 

 

 

 

dynamic

-

dynamic

no annotation needed

All JS 'classes' are dynamic by nature, so there's no need for this keyword?

final

-

final

no annotation needed

Is this a runtime attribute, or is it handled at compile time? If the latter, we can just leave it out as attempts to subclass this type are handled (blocked) on the AS side anyway?

internal

-

internal

no annotation needed

Same as with 'final'?

native

-

[not user accessible]

no annotation needed 

 

override

-

override function myFunction()

/**
 * @override
 */
function myFunction()

 

private

-

private

/**
 * @private
 */

 

protected

-

protected

/**
 * @protected
 */

 

public

-

public

no annotation needed

All JS entities are public by nature, so there's no need for this keyword?

static

-

static

check "diff" page

 

 

 

 

 

 

Definition keywords

 

 

 

 

... (rest) parameter

-

...rest

[leave out]

All JS functions allow an arbitrary number of arguments, so there's no need for this keyword?

class

-

class

function

Please see "Class" in the Class section, above.

const

-

const

/**
 * @protected
 */

 

extends

-

extends MyBaseClass

/**
 * @extends 

Unknown macro: {MyBaseClass}


 */

 

function

-

function

function

 

get

-

get

?

 

implements

-

implements MyInterface

/**
 * @extends \{MyInterface} 
 */

 

interface

-

interface

/**
 * @interface
 */

 

namespace

-

namespace

?

 

package

-

package my.package

goog.provides("my.package.MyClass")

 

set

-

set

?

 

var

-

var

var

 

 

 

 

 

 

Directives

 

 

 

 

default xml namespace

-

default xml namespace

See "E4X" page...

 

import

-

import my.package.MyOtherClass

goog.requires("my.package.MyOtherClass");

 

include

-

include

?

 

use namespace

-

use namespace

?

 

 

 

 

 

 

Namespaces

 

 

 

 

AS3

-

?

?

I'm not familiar with this in AS, so can't figure out what, if anything, might 'replace' this in JS.

flash_proxy

-

?

?

I'm not familiar with this in AS, so can't figure out what, if anything, might 'replace' this in JS.

object_proxy

-

?

?

I'm not familiar with this in AS, so can't figure out what, if anything, might 'replace' this in JS.

 

 

 

 

 

Primary expression keywords

 

 

 

 

false

-

false

false

 

null

-

null

null

 

this

-

this

Any method in which "this" is referenced should have the following in it's JSDoc block
/**
 * @this {TypOfClassToWhichMethodBelongs}  */
this

 

true

-

true

true

 

 

 

 

 

 

  • No labels