j2js

 

PresentationBasicTransformations

Page history last edited by Anonymous 4 yrs ago

Basic Java to Javascript Transformations

 

Basic transformation example

 

public class Foo extends Bar {

private int _field;

public Foo() {

_field = 5;

}

public int getField() {

return _field;

}

}

 

Becomes:

 

function Foo() {

this._field = 5;

}

Foo.prototype = new Bar();

Foo.prototype.constructor = Foo

Foo.superclass = Bar.prototype;

Foo.prototype.CLASS_NAME = "Foo";

Foo.prototype.getField = function() {

return this._field;

}

 

Other easy transformations: static properties and methods, translating to built-in functions

 

Next: PresentationMoreComplicatedStuff

Comments (0)

You don't have permission to comment on this page.