js基础题

const info = {
  [Symbol('a')]: 'b'
}

console.log(info)
console.log(Object.keys(info))
js基础题_第1张图片
image.png

Obeject. keys无法遍历symbol类型的属性

class Person {
  constructor() {
    this.name = "Lydia"
  }
}

Person = class AnotherPerson {
  constructor() {
    this.name = "Sarah"
  }
}

const member = new Person()
console.log(member.name)
js基础题_第2张图片
image.png
function nums(a, b) {
  if
  (a > b)
  console.log('a is bigger')
  else 
  console.log('b is bigger')
  return 
  a + b
}

console.log(nums(4, 2))
console.log(nums(1, 2))
js基础题_第3张图片
image.png

B return 不能换行,不然return undefined

你可能感兴趣的:(js基础题)