I always thought that one of the advantages of using this formulation of console.log will save you from null pointer exceptions and the like:
var c = undefined;
console.log(c,"foo");
now we get
"undefined 'foo'"
however, there doesn't really seem to be much of an advantage, since using the + operator seems to coerce null's and undefined's into strings before concatenation:
var c = undefined;
console.log(c + "foo");
this simply logs
"undefinedfoo"
Is there any way to get a null pointer or some error thrown from concatenating strings with the +
operator or console.log(x,y)
in JS? You of course can get a null pointer exception/error doing undefined.concat('foo')
.
is there any way to get a null point exception when concatenating Strings in JavaScript?