Skip to content

Comment on Advanced objects in JavaScript

Comments

You can use Object.getOwnPropertyNames to get all the properties defined on an object. This might be a nice alternative to a for in loop.

Careful. These have different behavior for own properties which are not enumerable. A for-in loop doesn't include them, but Object.getOwnPropertyNames does.

Right Object.keys(foo) is better.

And I also missed out on including this, thank you.

Nice catch, I will update the blog post.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.