Skip to content

Instantly share code, notes, and snippets.

@ruanyf
Created January 20, 2017 09:21
Show Gist options
  • Save ruanyf/73ac5e6139311e706cb4b77cc3823e55 to your computer and use it in GitHub Desktop.
Save ruanyf/73ac5e6139311e706cb4b77cc3823e55 to your computer and use it in GitHub Desktop.
默认参数不是传值调用
let x = 99;
function foo(p = x + 1) {
console.log(p);
}
foo() // 100
x = 100;
foo() // 101
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment