Skip to content

Instantly share code, notes, and snippets.

@iamsaief
Created August 22, 2020 12:16
Show Gist options
  • Save iamsaief/f92e3b34d1909d0e7cfe1195d73eec82 to your computer and use it in GitHub Desktop.
Save iamsaief/f92e3b34d1909d0e7cfe1195d73eec82 to your computer and use it in GitHub Desktop.
/* class, constructor, object */
class Student {
constructor(name, id) {
this.name = name;
this.id = id;
this.university = "Harvard University";
}
}
const student1 = new Student("Tom Hardy", 101);
const student2 = new Student("Chris Hemsworth", 102);
console.log(student1, student2);
console.log(student1.name, student2.name);
/**
* Output :
Student {
name: 'Tom Hardy',
id: 101,
university: 'Harvard University'
} Student {
name: 'Chris Hemsworth',
id: 102,
university: 'Harvard University'
}
*/
// Output: Tom Hardy Chris Hemsworth
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment