Constructor vs Field declaration

JavaScript performance comparison

Test case created by BenLorantfy

Preparation code

Benchmark.prototype.setup = function() {
  class MyClass {
    constructor() {
      this.x = 0;
      this.y = 0;
  class MySecondClass {
    x = 0;
    y = 0;


Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
Constructor Initialization
new MyClass();
Field declaration Initialization
new MySecondClass();

You can edit these tests or add even more tests to this page by appending /edit to the URL.

Compare results of other browsers