对javascript应用()问题 [英] Apply() question for javascript

查看:63
本文介绍了对javascript应用()问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我研究以下代码来记录

console.log.apply( console, arguments );

apply()

为什么不只是 console.log(message,参数)

谢谢。

推荐答案

apply()函数调用另一个函数,给定这个值和参数作为数组提供。

The apply() function calls another function with a given this value and arguments provided as an array.

隐含 func.apply(obj,args)的原因是为了确保在 func()指的是 obj

The reason for an implicit func.apply(obj, args) is to make sure that within func(), this refers to obj.

这篇关于对javascript应用()问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆