[英]What does “push” mean in evaluation of Chrome DevTools-Console?
When I evaluate one specific variable in Chrome DevTools - Console , this is the result:当我在Chrome DevTools - Console中评估一个特定变量时,结果如下:
(3) [Array(2), Array(2), Array(2), push: ƒ]
I know the f means, the array contains a function.我知道 f 的意思,数组包含一个 function。
What does the word push stand for in this context?在这种情况下,推这个词代表什么?
It means that someone has added a custom property to the array.这意味着有人向数组添加了自定义属性。 It's not the standard
Array.prototype.push
, it's something else.它不是标准的
Array.prototype.push
,它是别的东西。
const arr = [1, 2]; arr.push = () => 'some custom implementation'; console.log(arr);
If the standard .push
was there, it wouldn't be showing up in the console.如果标准
.push
在那里,它就不会出现在控制台中。
(Try to avoid this in professional code. It's weird.) (尽量在专业代码中避免这种情况。这很奇怪。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.