Test name | Executions per second |
---|---|
Prototype | 287558.0 Ops/sec |
Object Return | 1039786.1 Ops/sec |
<div>Yolo</div>
console.log("js preparation");
function Person() {
}
Person.prototype.add = function(a, b) {
return a + b;
};
Person.prototype.subtract = function(a, b) {
return a - b;
};
var dude = new Person;
dude.subtract(10, 5);
function person() {
return {
add: function(a, b) {
return a + b;
},
subtract: function(a, b) {
return a - b;
}
};
}
var dude = new person();
dude.subtract(10, 5);