Skip to content

Instantly share code, notes, and snippets.

@natafaye
Created June 29, 2022 03:36
Show Gist options
  • Save natafaye/f6ba4ba900c84f2b5882115cbd5b81e4 to your computer and use it in GitHub Desktop.
Save natafaye/f6ba4ba900c84f2b5882115cbd5b81e4 to your computer and use it in GitHub Desktop.
class User {
constructor(username) { // firstName = "Natalie"; lastName = "Childs"
this.username = username;
this.isAdmin = false;
}
greet() {
alert("Hello " + this.username + "!")
}
}
// Object we are stamping out
//const natalie = new User("nataliechilds");
// const natalie = {
// username: "nataliechilds",
// isAdmin: false,
// greet() {
// alert("Hello " + this.username + "!")
// }
// }
//natalie.greet();
//const abcde = new User("abcde");
// const abcde = {
// username: "abcde",
// isAdmin: false,
// greet() {
// alert("Hello " + this.username + "!")
// }
// }
//abcde.greet();
const users = [
new User("nataliechilds"),
new User("abcde")
]
//users[1].greet()
const natalie = users[0]
natalie.username = "thecoolestchilds";
//users[0].greet()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment