Chrome开发者控制台输出未定义 [英] Chrome dev console outputting undefined
问题描述
每次我在网站上看到一些javascript代码时,我都想在Chrome开发人员的工具控制台上键入并试用它,而不是创建一个javascript文件,然后在浏览器中单独打开它.
Every time i see some javascript code on a website, I feel like typing and trying it out on the Chrome's developer's tool console instead of creating a javascript file and then opening it separately in the browser.
就像今天一样,我正在查看道格·克罗克福德(Doug Crockford)的Js演讲,并同时对他所说的要交叉检查该功能的内容进行测试.
Like today, I was viewing Doug Crockford's Js lecture and kept simultaneously running test on whatever he was saying to cross check that feature.
我在javascript控制台中注意到的一件奇怪的事情是,由于我执行的任何语句都不会产生固定值,因此它始终输出未定义的值,如下所示:
A strange thing that I noticed in the javascript console is that it always outputs the value undefined as a result of any statement that I execute that does not produce a fixed value as below:
var x = 12;控制台o/p<未定义
var x = 12; Console o/p < undefined
2 + 3控制台o/p<5
2+3 Console o/p < 5
+"46"<46
+"46" < 46
未定义的值表示每次声明后哪个Chrome开发者控制台.
What does the undefined value mean which Chrome dev console after every declaration.
推荐答案
如果键入时不带"var",则只需
If you type it without "var", just
x = 12;
它将输出12;但无论如何,这是一个重复的问题: Chrome/Firefox console.log始终添加一行,表示未定义和这是什么意思,如果console.log(4)在Chrome控制台中未定义输出?
it will output 12; but in any case, this is a duplicate question of: Chrome/Firefox console.log always appends a line saying undefined and What does it mean if console.log(4) outputs undefined in Chrome Console?
这篇关于Chrome开发者控制台输出未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!