What is the difference between call and apply?

前端 未结 24 1689
太阳男子
太阳男子 2020-11-21 07:12

What is the difference between using call and apply to invoke a function?

var func = function() {
  alert(\'hello!\');
};
         


        
24条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-21 07:47

    Here's a good mnemonic. Apply uses Arrays and Always takes one or two Arguments. When you use Call you have to Count the number of arguments.

提交回复
热议问题