JSFiddle - React, Tailwind, and code Playground

by Uday Hiwarale

JavaScript

class MyObject {
	constructor( fn, ln, age ) {
  	this.firstName = fn;
    this.lastName = ln;
    this.age = age;
  }

	*[Symbol.iterator]() {
    const values = Object.values(this);
    let value;

    while (value = values.shift()) {
      yield value;
    }
  }
}

var myObject = new MyObject( "John", "Doe", 26 );

console.log(...myObject); // John Doe 26