-
Notifications
You must be signed in to change notification settings - Fork 2
Home
JS2- JavaScript Sugar
JS2 is syntactic sugar on top of JavaScript. It adds common programming functionality to JavaScript that was inspired by other languages (Java, Ruby, Perl). Since JS2 is a superset of JavaScript, JavaScript remains fully compatible with JS2. JS2 is available in 4 different flavors and is written in JavaScript:
Example:
class Vehicle {
function move() {
return "I move";
}
}
class Car extends Vehicle {
function move() {
return "I roll";
}
}
class SportsCar extends Car {
function move() {
return this.$super + ' quickly';
}
}
var ferrari = new SportsCar();
console.log(ferrari.move());
JS2 was designed to service various JavaScript environments. You can use it whether you are using a client-side browser JavaScript or a server-side implementation such as ringojs or nodejs. There are, however, different strategies.
Install JS2: (here)Installation
gem install js2
# or
npm install js2
# or
ringo-admin install jeffsu/js2-ringo
Create project directory structure
mkdir -p myproj/lib myproj/src
Create js2 files
vi myproj/src/Foo.js2
For more detailed instructions, go here.
# for ruby mri
gem install rubyracer
gem install js2
This is the fastest implementation and is the preferred way to run compilations First, install nodejs and npm (node's package manager)
npm install js2
First, install ringo.
ringo-admin install jeffsu/js2-ringo
More information can be found here: Syntax