Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// const Animal = function() {
// this.speed = 0
// return {
// run: function() {
// this.speed += 10
// console.log(this.speed)
// }
// }
// }
// const Animal2 = () => {
// this.speed = 0
// return {
// run: () => {
// this.speed+=10
// console.log(this.speed)
// }
// }
// }
// class Animal3 {
// constructor(ops = 0) {
// this.speed = ops
// }
// run() {
// this.speed+=10
// console.log(this.speed)
// }
// }
// class SuperAnimal extends Animal3 {
// constructor() {
// super()
// }
// run() {
// this.speed += 100
// console.log(this.speed)
// }
// }
// const horse = new Animal3(10)
// horse.run()
// const superHorse = new SuperAnimal()
// superHorse.run()
const f = () => {}
const fieldName = 'my name'
const obj = {
f,
run() {
let secretValue = 10;
},
[Math.random()]: 'random value',
[fieldName]: Math.random(),
firstName: 'Kaiser',
lastName: "Permanente",
get fullName() {return this.firstName+this.lastName},
set phone(value) {this.phoneNumber = value.trim()}
}
// obj[fieldName] = text
obj.phone = '555-123-4545 '
console.log(obj.phoneNumber+'end')
obj.phoneNumber = '123'
console.log(obj.phoneNumber+'end')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.