whitespace - JavaScript ignores extra spaces? -
in javascript quiz @ wscube tech there question whether javascript ignores spaces. correct answer “false”.
isn’t javascript white-space independent? have read in many blogs is. why answer wrong?
i seriously wouldn’t trust site…
that’s short, sufficient answer give, i’d 2 other things:
firstly, javascript doesn’t ignore spaces within strings:
var str = "hello world";
this string has 16 spaces , won’t ignored that. however, in-between operators, keywords , tokens, javascript ignore spaces:
var test = [ 0 , 1 , 3 ] . slice ( 2 ) ;
this line parsed as
var test=[0,1,3].slice(2);
still, space between var
, test
isn’t ignored. not spaces equal. quiz question cannot answered in current form — well, or 2 forms…
secondly, quiz has lot of inconsistencies, false information, outdated information , promotes bad practice. i’ve sent them huge list of things wrong quiz…
it’s safer stick more “trusted” site mozilla developer network.
Comments
Post a Comment