We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
slice
splice
var xs = [1,2,3,4,5]; // 纯的 xs.slice(0,3); //=> [1,2,3] xs.slice(0,3); //=> [1,2,3] xs.slice(0,3); //=> [1,2,3] // 不纯的 xs.splice(0,3); //=> [1,2,3] xs.splice(0,3); //=> [4,5] xs.splice(0,3); //=> []
// 不纯的,引用了外部变量 let adultAge = 21; const checkAge = function(age) { return age >= adultAge; }; // 纯的 const checkAge = function(age) { let adultAge = 21; return age >= adultAge; };
The text was updated successfully, but these errors were encountered:
No branches or pull requests
一等公民
纯函数
slice
和splice
方法,他们作用很相似,slice符合纯函数的定义,因为它不会改变原数组的值,输入相同的参数,一定会得到相同的返回值。而splice在调用时就永久的改变了原数组的值(产生副作用了!)。柯里化
The text was updated successfully, but these errors were encountered: