Object Creation
JavaScript performance comparison
Info
A deeper look into http://www.aminutewithbrendan.com/pages/20110216
Preparation code
<script>
function ClosurePattern() {
this.someMethod = function someMethod() {
console.log('foo');
}
}
function PrototypalPattern() {}
PrototypalPattern.prototype = {
someMethod: function() {
console.log('foo');
}
}
function sm() {
console.log("foo")
}
function PrototypalWithHoisting() {}
PrototypalWithHoisting.prototype = {
someMethod: sm
}
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
Closure Pattern |
|
pending… |
Prototypal Pattern |
|
pending… |
Prototypal Hoisting Pattern |
|
pending… |
You can edit these tests or add even more tests to this page by appending /edit to the URL.
0 comments