LearnFrenzy
Sign in Take a free test
JS

JavaScript Programming · Topic 11 of 25

Objects Questions and Concepts

  • 4 exercises
  • 60 questions
  • ~60 min
  • Answers explained

Interview Questions

Objects · Study material

JavaScript Objects – Interview Questions

1. What is the difference between dot and bracket notation?

Dot notation needs a literal, valid identifier (obj.name). Bracket notation takes any string or expression (obj["first-name"], obj[key]).

2. How do you check whether an object has a property?

Object.hasOwn(obj, key) (or obj.hasOwnProperty(key)) for own properties; key in obj also checks the prototype chain.

3. What is the difference between Object.freeze and Object.seal?

freeze makes every own property read-only and blocks adding or deleting; seal blocks adding and deleting but allows changing existing values. Both are shallow.

4. How do you copy an object?

Shallow: { ...obj } or Object.assign({}, obj). Deep: structuredClone(obj). Assignment copies only the reference.

5. What is this inside an object method?

The object the method was called on (the value before the dot). Detached calls lose it: undefined in strict mode, the global object otherwise. Arrow functions do not have their own this.

6. What do Object.keys, Object.values and Object.entries return?

Arrays of the object's own enumerable string-keyed property names, values, or [key, value] pairs.

7. What happens when you use an object as a key in another object?

It is converted to the string "[object Object]", so all object keys collide. Use a Map or WeakMap.

8. What are getters and setters?

Accessor properties: a get function runs when the property is read and a set function when it is assigned – used for computed values and validation.

9. What is a property descriptor?

The attributes of a property: value, writable, enumerable, configurable (or get/set). Read with Object.getOwnPropertyDescriptor, set with Object.defineProperty.

10. What is the prototype chain?

The linked series of prototype objects JavaScript searches when a property is not found on the object itself; it ends at Object.prototype and then null.

11. What does Object.create(null) create?

An object with no prototype – no toString, hasOwnProperty or other inherited keys – useful as a pure dictionary.

12. What does JSON.stringify do with undefined, functions and Dates?

undefined and function properties are omitted (null inside arrays), Dates become ISO strings, NaN/Infinity become null, BigInt and circular references throw.

13. How do you compare two objects for equality?

=== checks identity. For content, compare keys and values recursively (a deep-equal function) – JSON.stringify comparison breaks with different key orders.

14. What is the difference between spread and Object.assign?

Both copy own enumerable properties shallowly. Object.assign mutates its target and triggers setters on it; spread always creates a new object.

15. In what order are object keys listed?

Integer-like keys in ascending order first, then string keys in insertion order, then symbols (only by getOwnPropertySymbols / Reflect.ownKeys).

Ready to test your Programming?

Timed online tests with instant scores and explanations.

About this section

About JavaScript Programming

Why it matters

  • JavaScript runs every web page and, with Node.js, servers, tools and APIs – it is the most used language in the world
  • Front-end, full-stack and MERN roles test JavaScript first, and many campus coding rounds allow it
  • "Predict the output" questions on hoisting, closures, this, coercion and the event loop are interview favourites
  • Modern ES6+ – let/const, arrow functions, destructuring, promises and async/await – is what companies expect from freshers

Who it is for

  • College students (B.Tech, BCA, MCA, B.Sc CS) learning web development and preparing for semester exams and viva
  • Freshers preparing for campus placements, online assessments and front-end interviews
  • Developers moving to React, Angular, Vue or Node.js who need strong core JavaScript
  • Anyone revising ES6 and asynchronous JavaScript before an interview

What every topic gives you

  • Study material in five tabs: concepts with runnable examples, coding techniques, programs, interview questions and a cheat sheet
  • Topic-wise MCQs on concepts and ES6 features
  • "Predict the output" puzzles – hoisting, coercion, closures, promises and timers
  • "Find the error" debugging: SyntaxError, ReferenceError, TypeError and silent logic bugs
  • Coding problems with solutions and real output, every one run on Node.js – run any study example in your browser

Asked in

  • Campus placements
  • TCS, Infosys, Wipro, Accenture, Cognizant tests
  • Front-end developer interviews
  • MERN / full-stack interviews
  • Online coding assessments
  • University practicals

How to use this section

  1. Read the study material of a topic and run the examples in the browser.
  2. Practise the four exercises – MCQs, output, debugging, coding problems – each marked Easy, Medium or Hard, and read every explanation.
  3. Revise with the interview questions and cheat sheet, then move to the next topic.

Search LearnFrenzy

Esc

Quick links