EvilScript: Download it now!
Monday, May 5th, 2008So I have cleaned up EvilScript, now a full featured downloadable thing. Its actually basically one function, about 30 lines. It allows you to write JS in a “classical” style, if thats your thing. The name “EvilScript” should give you an idea how I feel about the idea, but I spent this evening cleaning this up, so enjoy. Download the minified file here.
Using this is really simple. No support for public/private methods, but this is really just object cloning with inheritance:
var vehicle = {
_init:function(){
console.log('vi');
},
numwheels:0,
running:false,
start:function(){
this.running = true;
},
stop:function(){
this.running = false;
},
isRunning:function(){
return this.running;
},
setWheelNum:function(num){
this.numwheels = num;
},
getWheelNum:function(){
return this.numwheels;
}
};
var car = {
extend:vehicle,
_init:function(fueltype){
this.fueltype = fueltype;
},
fueltype:'',
getFuelType:function(){
return this.fueltype;
}
};
var myVehicle = evil.alloc(vehicle);
var myCar = evil.alloc(car, ['unleaded']);
log(myVehicle.isRunning());
myVehicle.start();
log(myVehicle.isRunning());
log('Car:‘);
log(’fuel: ‘+ myCar.getFuelType());
log(myCar.isRunning());
myVehicle.start();
log(myCar.isRunning());