javascript - Why does jslint prefer {}.constructor(obj) over Object(obj) -


both detect objects , not primitives.

it seems purely syntactical difference.

// jslint prefers {}.constructor(obj) on object(obj) // called isobject underscore // test objects have writable keys // example string literals not detected // arrays var iswritable = function (obj) {     return {}.constructor(obj) === obj; }; 

i'm not quite sure, shouldn't. if you're looking @ performance, that's opposite of should doing.

according this jsperf test available compares speed of creating via new object(), object.create().new(), , object.prototype.constructor() (which same object.constructor()); object.constructor() slowest 1 of them all far.

google's v8 engine magnitudes faster using new object() because optimizes call heavily, wouldn't worry it.

results jsperf test:

operation per second comparison of object creation functions the graph results of speed of different object creation functions in multiple browsers


Comments

Popular posts from this blog

rdbms - what exactly the undo information lives in oracle? -

bash - How do you programmatically add a bats test? -

java - Getting exception in JDBC thin driver -