Skip to content

Instantly share code, notes, and snippets.

@azat-co
Created September 19, 2018 23:31
Show Gist options
  • Save azat-co/96ed9b2d99fa51964bc5429a60a21420 to your computer and use it in GitHub Desktop.
Save azat-co/96ed9b2d99fa51964bc5429a60a21420 to your computer and use it in GitHub Desktop.
// 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