Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Object.defineProperty
var foo = {}
Object.defineProperty(foo, 'name', {
configurable: true, //是否可以delete foo.delete
enumerable: true, // 是否for in可以返回属性
writable:true, //是否可以重新赋值
value: 'kobe'
})
var descriptor = Object.getOwnPropertyDescriptor(foo, 'name')
console.log(descriptor.value)
console.log(foo.name) // kobe
@Yang03

This comment has been minimized.

Copy link
Owner Author

Yang03 commented Oct 10, 2017

function sum(list) {
  if (list.length === 0) {
    return 0;
  } else {
    const [atom, ...remainder] = list;
    const left = atom;
    const right = sum(remainder);

    return left + right;
  }
}

sum([42, 3, -1])

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.