// Arguments 对象
// https://www.cnblogs.com/huangwenjietk/p/10850307.html
// arguments实质上是所在函数的一个内置类数组对象
// arguments不是数组,而是一个对象
// arguments对象还有callee、length、迭代器等属性
// function fun() {
// console.log(typeof arguments)
// console.log(arguments.callee === fun)
// console.log(arguments.length)
// }
// fun()
// 理解点一:可以通过arguments对象来访问函数所有的实参
// function add() {
// console.log(arguments[0])
// console.log(arguments[1])
// console.log(arguments[2])
// }
// add(11, 22, 33)
// 理解点二:在正常模式下,可以通过arguments来改变函数实参
// function add(a, b) {
// arguments[0] = 4
// arguments[1] = 5
// return a + b
// }
// console.log(add(3, 5))
// 理解点三:在严格模式下,不允许通过arguments对象来改变函数调用时传来的实参值
// function add(a, b) {
// 'use strict'
// arguments[0] = 4
// arguments[1] = 5
// return a + b
// }
// console.log(add(3, 4))
// 理解点四:通过arguments的length属性,能够判断函数的实参个数
// function add() {
// console.log(arguments.length)
// }
// add(11, 22, 33, 44)
// add(2)
// 理解点五:arguments是一个对象而不是数组,转换成数组
// function add() {
// // slice并没有改变原数组,而是返回一个新数组
// const arr = Array.prototype.slice.call(arguments)
// console.log(typeof arr)
// console.log(arr)
// }
// add(11, 22, 33)
// function add() {
// let arr = []
// for (let i = 0; i < arguments.length; i++) {
// arr.push(arguments[i])
// }
// return arr
// }
// console.log(add(11, 22, 33))
// const demoArr = [11, 22, 33]
// const newArr = demoArr.slice()
// console.log(newArr === demoArr)
// 理解点六:arguments对象的callee属性指向其自身
// function add() {
// console.log(arguments.callee === add)
// }
// add()
// arguments的应用
// 一、判断形参和实参的个数是否一致
// function add(a, b) {
// console.log(add.length)
// console.log(arguments.length)
// console.log(add.length === arguments.length)
// }
// add(11, 22, 33)
// 二、arguments对象的callee属性指向其自身,来应用到递归中去
// function add(n) {
// if (n === 1) {
// return 1
// } else {
// return n + arguments.callee(n - 1)
// }
// }
// console.log(add(2))
// 三、编写一个函数求传入的若干个数字(不能用数组显示传入)的和
function add() {
let sum = 0
for(let i =0; i < arguments.length; ) {
}
}
console.log(add(11, 22, 33))
console