当我运行代码时:
function F35() { return this; }
F35.Speed = 2600;
console.log('Here is the function:', F35);
console.log('Here is the property:', F35.Speed);
输出是这样的:
Here is the function: ƒ F35() { return this; }
Here is the property: 2600
允许我打开其属性的函数附近没有箭头符号。如果我记录一个对象,这是可能的。我可以对功能做同样的事情吗?每个函数都有额外的属性,例如原型(prototype)等等。
最佳答案
您可以使用 console.dir
而不是 console.log
查看有关函数的扩展信息:
console.dir(F35);
具体来说:
The
Console
methoddir()
displays an interactive list of the properties of the specified JavaScript object
关于这个的信息是here .
关于javascript - 有没有办法在 Chrome 控制台中将 JavaScript 函数视为对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58833147/