coffee CLI
real 0m0.124s
user 0m0.102s
sys 0m0.022s
Cat.prototype.meow = function(message) { | |
this.emit('meow', message); | |
} | |
// Create a cat | |
var kitty = new Cat('Mittens'); | |
kitty.on('meow', function(msg) { | |
console.log('We got a message from Mittens:', msg); | |
}); | |
kitten.on('meow', function(msg) { | |
console.log(msg); | |
}); |
kitten.emit('meow', msg); |
var foo = 10; // any value works | |
foo.__proto__.test = function() { | |
console.log("Success"); | |
}; | |
foo.test(); |
// This is the constructor | |
function Client(name, age) { | |
this.name = name; | |
this.age = age; | |
} | |
Client.prototype.contact = function() { | |
console.log("Now contacting " + this.name + "..."); | |
} |
Client.prototype.zipcode = 12345; | |
// Utilizes a closure | |
Client.prototype.defaultAge = (function() { | |
return prompt("What should the default age be?"); | |
})(); |
function Person(age) { | |
if (age > 18) this.age = age; | |
} | |
Person.prototype.age = 18; |
{ | |
"name": "bench", | |
"version": "0.0.2", | |
"repo": "brendanashworth/bench", | |
"description": "Easy to use, beautiful-looking benchmarking library", | |
"keywords": ["benchmark", "bench", "speed"], | |
"license": "MIT", | |
"src": ["bench.h", "bench.c"] | |
} |
total = 0 | |
for num in [1..5000] | |
total += num | |
console.log total |