i wrote code in node.js console, , noticed return undefined
.
see following code.
some lines return undefined
don't.
undefined
mean?
ps d:\test\hello> node > "two\nlines" 'two\nlines' > var s = "hello, world" undefined > s.charat(0) 'h' > s.charat(s.length -1) 'd' > var anystring = 'mozilla'; undefined > console.log(anystring.substring(3, 0)); moz undefined
but last line , returns undefined returns moz?
> console.log(anystring.substring(3, 0)); moz undefined
console.log
explicitly outputs console, moz
you're seeing. returns value (or well, doesn't), value undefined
, logged console because you're in interactive environment , that's does.
the point of using interactive command line able try operations , see result instantly, without complex alert
or debugging setups. type command, see result. result value undefined
, it's value.
Comments
Post a Comment