如何在JavaScript中输出调用对象? [英] How to output call object in javascript?

查看:95
本文介绍了如何在JavaScript中输出调用对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



调用对象使用一个名为arguments的属性进行初始化,该属性引用了Arguments对象函数

是否允许使用console.log或alert()方法输出JavaScript中调用对象的结构(或值?)



当人们说'一个调用对象',它是一个概念还是一个对象?

解决方案

我相信他们指的是调用方法/函数的对象。



可以通过 this
$ b

 < a onclick =foo()>点击我< / a> 

函数foo(){
this.style.color ='#cc0000';
alert(arguments.length);
}

此代码会将锚点的文本颜色更改为#cc0000,然后警报0。


while I was reading a javascript book, I read the following sentence.

"The call object is initialized with a property named arguments that refers to the Arguments object for the function"

am I allow to output the structure (or values?) of a call object in javascript using console.log or alert() method??

when people say 'a call object', is it a concept or an object?

解决方案

I believe they are referring to the object calling the method/function.

This can be referenced by the this keyword

<a onclick="foo()">click me</a>

function foo(){
  this.style.color='#cc0000';
  alert(arguments.length);
}

This code would change the text color of the anchor to '#cc0000' and alert 0.

这篇关于如何在JavaScript中输出调用对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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