Created
February 4, 2020 18:28
-
-
Save fkleuver/cedbc4729e4477ac5942f5b6adae53fe to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ES6 class | |
| function testClass(N){ | |
| class Foo { | |
| constructor(prop1, prop2) { | |
| this.prop1 = prop1; | |
| this.prop2 = prop2; | |
| } | |
| get getter1() {} | |
| method1() {} | |
| method2() {} | |
| } | |
| for (let i = 0; i < N; ++i){ | |
| new Foo(i, null); | |
| } | |
| } | |
| testClass(1e6); | |
| // ES5 prototype | |
| function testClass(N){ | |
| function Foo(prop1, prop2) { | |
| this.prop1 = prop1; | |
| this.prop2 = prop2; | |
| } | |
| Foo.prototype.method1 = function () {}; | |
| Foo.prototype.method2 = function () {}; | |
| Object.defineProperty(Foo.prototype, 'getter1', { get() {}, configurable: true }); | |
| for (let i = 0; i < N; ++i){ | |
| new Foo(i, null); | |
| } | |
| } | |
| testClass(1e6); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment