ES6 Classes — JS Technical Interview Questions & Answers

class syntax over prototypes.

ES6 Classes

  • ES6 Classes (js) is a JS topic. In plain words you use it for a short ES6 Classes js example in a script in the browser. Don’t start with a slogan — start with that picture.
  • Smallest example: the smallest ES6 Classes js example you can type. Type it, run it, and say what you see. If you can do that from memory, you know ES6 Classes (js).
  • From the example next to this theory: class syntax over prototypes.
  • Trap: only saying “ES6 Classes js” with no example. Fix that before you talk about advanced JS.
  • Viva: what is ES6 Classes (js)? Then show the smallest ES6 Classes js example you can type. Then name the trap.

Technical Interview Tip: What is ES6 Classes (js)? Show this: the smallest ES6 Classes js example you can type. Trap: only saying “ES6 Classes js” with no example.

Code Examples for ES6 Classes

ES6 Classes — working example

class Person {
  constructor(name) {
    this.name = name;
  }
  greet() {
    return "Hi " + this.name;
  }
}

class Student extends Person {
  constructor(name, track) {
    super(name);
    this.track = track;
  }
}

const s = new Student("Ada", "JS");
console.log(s.greet(), s.track);
console.log(Object.getPrototypeOf(s) === Student.prototype);

ES6 Classes — eS classes are sugar over prototypes; extends sets up the prototype chain; super calls the parent.

How to Explain ES6 Classes to an Interviewer

What is ES6 Classes (js)?

Used for a short ES6 Classes js example a script in the browser Not just the heading

Give one small example of ES6 Classes (js).

the smallest ES6 Classes js example you can type class syntax over prototypes

What mistake do beginners make with ES6 Classes (js)?

only saying “ES6 Classes js” with no example Show the fix

Where do you use ES6 Classes (js)?

a script in the browser a short ES6 Classes js example