Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
javascript new vs Object.create 3
(version: 0)
Comparing performance of:
Object.create vs new vs simple
Created:
3 years ago
by:
Guest
Go to the latest result
Tests:
Object.create
let bar = Object.create(Object.prototype);
new
let foo = new Object();
simple
let bax = {};
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
Object.create
new
simple
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:134.0) Gecko/20100101 Firefox/134.0
Browser/OS:
Firefox 134 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
new
1525.7M/s
simple
1458.6M/s
Object.create
1286.3M/s
View exact numbers
Test name
Executions per second
✓
new
1,525,710,080 Ops/sec
simple
1,458,555,136 Ops/sec
Object.create
1,286,338,304 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
I'd be happy to explain the benchmark being measured. **What is being tested?** The benchmark measures the performance of three different ways to create objects in JavaScript: `new`, `Object.create`, and a "simple" approach using an empty object literal `{}`. **Options compared** The benchmark compares the performance of these three approaches because they have different characteristics that can impact execution speed: 1. **`new Object()`**: This creates a new, empty object with its own prototype chain. It's a simple and straightforward way to create an object. 2. **`Object.create(Object.prototype)`**: This method creates a new object with the prototype of `Object.prototype`. This approach allows for more control over the prototype chain, but can be slower than using the `new` operator. 3. **Simple approach: `{}`**: This creates a new object by simply creating an empty object literal. This is often considered the fastest way to create an object in JavaScript. **Pros and cons of each approach** 1. **`new Object()`**: * Pros: Simple, efficient, and widely supported. * Cons: Can lead to unexpected prototype chain behavior if not used carefully. 2. **`Object.create(Object.prototype)`**: * Pros: Provides more control over the prototype chain, which can be useful in certain situations. * Cons: May be slower than using `new`, especially for simple objects. 3. **Simple approach: `{}`**: * Pros: Fastest way to create an object, with minimal overhead. * Cons: May not provide any additional benefits or control over the prototype chain. **Library usage** None of the test cases use any external libraries. **Special JavaScript features or syntax** The benchmark does not use any special JavaScript features or syntax that might affect its results. It only uses standard ECMAScript syntax. **Other alternatives** If you're interested in optimizing object creation, you may also consider using techniques like: * Creating objects on the stack instead of the heap (not applicable here) * Using `Object.assign()` to create new objects from existing ones * Using `Object.create()` with a custom prototype object However, for simple cases, the `new Object()` and simple `{}` approaches are usually sufficient.
Related benchmarks
javascript new vs Object.create
javascript new vs Object.create 2
Comments
Confirm delete:
Do you really want to delete benchmark?