Object creation (v2)

Revision 2 of this benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
new Object
{}
ready
class Instance
class Foo {}
new Foo()
ready
create instance with defaults
class Foo {
	constructor(name, value) {
		this.name = name
		this.value = name
	}
}
new Foo("Foobar", 12)
ready
create object via function
function createObj(name, value) {
	return { name, value }
}
createObj("MyObject", 135)
ready
create object via new operator
new Object()
ready
create instance via Function
function MyClass() {}
new MyClass()
ready
create instance assign functions in constructor
class Foo {
	constructor() {
		this.foo = () => {}
		this.bar = () => {}
	}
}
new Foo()
ready
create instance with methods
class Foo {
	foo() {}
	bar() {}
}
new Foo()
ready

Revisions

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