admin管理员组文章数量:1333451
Take this simple Test object and paste it into the console. You'll see that it says undefined
. The object is working because it also prints 123
, but what is the undefined
about?
Test:
var Test = new (function(){
return {
get testing(){
return "123";
}
}
});
console.log(Test.testing);
Console Output:
123
undefined
Take this simple Test object and paste it into the console. You'll see that it says undefined
. The object is working because it also prints 123
, but what is the undefined
about?
Test:
var Test = new (function(){
return {
get testing(){
return "123";
}
}
});
console.log(Test.testing);
Console Output:
123
undefined
Share
Improve this question
edited Oct 20, 2020 at 17:16
Peter Mortensen
31.6k22 gold badges110 silver badges133 bronze badges
asked Nov 10, 2012 at 13:25
DrahcirDrahcir
12k25 gold badges88 silver badges128 bronze badges
1
- Possible duplicate: Why does this JavaScript code print "undefined" on the console? – Peter Mortensen Commented Oct 20, 2020 at 17:18
2 Answers
Reset to default 5That is the return value of console.log
.
Try
console.log(1);
which gives
1
undefined
However, if you type just
Test.testing
that gives only
"123"
undefined
is the return value from the console.log
call.
本文标签: javascriptWhy does Chrome amp FireFox console print 39undefined39Stack Overflow
版权声明:本文标题:javascript - Why does Chrome & FireFox console print 'undefined'? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742351158a2458520.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论