Skip to main content Accessibility Feedback

Objects

Object.keys()

Return an array of keys from an object. Pass in the object as an argument.

let lunch = {
	sandwich: 'turkey',
	chips: 'cape cod',
	drink: 'soda'
};

// logs ["sandwich", "chips", "drink"]
let keys = Object.keys(lunch);
console.log(keys);

Preorder my new course on Web Components! Want to learn how to build Web Components from scratch, master best practices, and more? Preorder today and get $100 off of the launch price.


Find this useful? You can support my work by purchasing an annual membership.