SOURCE

console 命令行工具 X clear

                    
>
console
// arguments

function fun() {
    // let arr = [...arguments]

    let arr = Array.prototype.slice.call(arguments)
    console.log(arr)

}

// arguments是类数组对象 通过扩展运算符可以变成数组
// fun(1,2,3)


function fun1() {
    let a = b = 0
    console.log(a, b)
}

fun1()

console.log('b', b, 'a')

// 哪些操作会造成内存泄漏

// 1. 闭包
// 2. 意外创建的全局变量
// 3. 遗忘的定时器
// 4. 脱离dom的引用


// 手写一个map 


function map(data, fun) {
    let result = []

    if (!Array.isArray(data) || !data.length || typeof fun !== 'function') {
        return []
    }

    for (let i = 0, len = data.length; i < len; i++) {
       result.push(fun(data[i], i, data))
    }

    return result
}


let res = map([1,2,3], (item) => {
    return item * 2
})

console.log(res)
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=, initial-scale=">
	<meta http-equiv="X-UA-Compatible" content="">
	<title>部分面试题</title>
</head>
<body>
	
</body>
</html>