JavaScript `in` operator

Understand the basics of JavaScriptinoperator

ThisinOperators are very useful. It allows us to check whether an object has attributes.

The operator returnstrueIf the first operand is an attribute of the object passed on the right, or an attribute of one of its ancestors in its prototype chain.

Otherwise returnfalse.


class Car {
  constructor() {
    this.wheels = 4
class Fiesta extends Car {
  constructor() {
    this.brand = 'Ford'

const myCar = new Fiesta() ‘brand’ in myCar //true ‘wheels’ in myCar //true

Download mine for freeJavaScript beginner's manual

More js tutorials: