1. 程式人生 > 其它 >猜猜什麼是回撥地獄?

猜猜什麼是回撥地獄?

// typeof與instanceof區別
var arr=[1,2,3,4,5];
// console.log(typeof arr); 返回object型別
// console.log(typeof{}); 返回object

// console.log(arr instanceof Array);確定是什麼型別的資料
// console.log({} instanceof Object);
// console.log(arr instanceof Object);

// call 與 apply 與 bind 的區別
// call呼叫object裡面的東西
// console.log( Object.prototype.toLocaleString.call(arr))
// console.log( Object.prototype.toLocaleString.apply(arr))
// bind返回的是函式的拷貝 如果要呼叫需要在後面加 ();
// console.log( Object.prototype.toLocaleString.bind(arr)())

// 高階函式(函式套函式)
// function f(){
// console.log("f()");
// }

// f()
// function f(){
// return function(){
// console.log("f()");
// }
// }
// f()()
// console.log(f())

// 回撥函式
// function f(fun,fun2){
// // arguments
// btn.click = function (){
// fun()
// fun2()
// }

// }

// function sum(){
// console.log("sum");
// }
// sum();
// f(sum);

// // 回撥地獄 這玩意務必避免掉
// function f(fun){
// fun();
// }
// f(f(f(f(f(f())))))