I like testing execution time with console.time(string) and console.timeEnd(string).
Though, as one could guess testing performance this way is a fail. It will give various results every time. You'd better use developer tools instead.
Anyway, Object.hasOwnProperty compared to prop in obj should be incredibly faster as the latter run through all the prototype chain of an object. I've run that tests on small objects and get what I expected.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I like testing execution time with
console.time(string)
andconsole.timeEnd(string)
.Though, as one could guess testing performance this way is a fail. It will give various results every time. You'd better use developer tools instead.
Anyway,
Object.hasOwnProperty
compared toprop in obj
should be incredibly faster as the latter run through all the prototype chain of an object. I've run that tests on small objects and get what I expected.