Reputation: 268
example from docs https://facebook.github.io/immutable-js/docs/#/Record
var ABRecord = Record({a:1, b:2})
var myRecord = new ABRecord({b:3})
can I omit new
operator? it seems to work without it as well..
Upvotes: 1
Views: 101
Reputation: 1101
At least in the current version, you can omit it. If you look into the source code on GitHub, there is a check that makes sure this
is correctly bound if you are omitting new
.
Upvotes: 0
Reputation: 76444
It is unsafe to omit it, you might encounter problems in future versions. You can easily test whether a given version of Immutable.js supports this feature, like this:
typeof (Record({})) === "function"
Upvotes: 1