Sitemap
Praveen Sripati

Praveen Sripati

A dedicated web developer with a strong background in technology. Love building stuff ❤️

JavaScript Object Methods CheatSheet (Quick Reference)

2 min readApr 9, 2026

--

If you only save one page for JavaScript objects — make it this one.

Press enter or click to view image in full size

📚 Official Docs: MDN Docs

📌 Index

  1. Object.keys()
  2. Object.values()
  3. Object.entries()
  4. Object.fromEntries()
  5. Object.assign()
  6. Object.hasOwn()
  7. Object.freeze()
  8. Object.seal()
  9. Object.create()
  10. Object.getPrototypeOf()

🚀 Methods Explained

1. Object.keys()

What it does: Returns all keys of an object

Example:

Object.keys({ a: 1, b: 2 });

Output:

["a", "b"]

2. Object.values()

What it does: Returns all values of an object

Example:

Object.values({ a: 1, b: 2 });

Output:

[1, 2]

3. Object.entries()

What it does: Returns key-value pairs as arrays

Example:

Object.entries({ a: 1, b: 2 });

Output:

[["a", 1], ["b", 2]]

4. Object.fromEntries()

What it does: Converts entries back to object

Example:

Object.fromEntries([["a", 1], ["b", 2]]);

Output:

{ a: 1, b: 2 }

5. Object.assign()

What it does: Merges objects (shallow copy)

Get Praveen Sripati’s stories in your inbox

Join Medium for free to get updates from this writer.

Example:

Object.assign({}, { a: 1 }, { b: 2 });

Output:

{ a: 1, b: 2 }

6. Object.hasOwn()

What it does: Checks if property exists (own property only)

Example:

Object.hasOwn({ a: 1 }, "a");

Output:

true

7. Object.freeze()

What it does: Prevents any changes to the object

Example:

const obj = Object.freeze({ a: 1 });
obj.a = 2;

Output:

{ a: 1 } // unchanged

8. Object.seal()

What it does: Allows updating values but prevents adding/removing keys

Example:

const obj = Object.seal({ a: 1 });
obj.a = 2;
obj.b = 3;

Output:

{ a: 2 } // 'b' not added

9. Object.create()

What it does: Creates a new object with a given prototype

Example:

const proto = { a: 1 };
const obj = Object.create(proto);
obj.a;

Output:

1

10. Object.getPrototypeOf()

What it does: Returns the prototype of an object

Example:

Object.getPrototypeOf({});

Output:

Object.prototype

🎯 Quick Mental Model

  • keys() → keys
  • values() → values
  • entries() → key + value
  • fromEntries() → reverse
  • assign() → merge
  • freeze() → lock
  • seal() → partial lock

🔥 Pro Tips

  • Prefer Object.hasOwn() over hasOwnProperty() ✅
  • Use entries → map → fromEntries for transformations 🚀
  • Object.assign() is shallow copy ⚠️
  • Use Object.freeze() for constants

--

--

Written by Praveen Sripati

A dedicated web developer with a strong background in technology. Love building stuff ❤️