whitespace - JavaScript ignores extra spaces? -


in javascript quiz @ wscube tech there question whether javascript ignores spaces. correct answer “false”.

7. javascript ignores spaces: ◉ true ✗ — ⭕ false ✓

isn’t javascript white-space independent? have read in many blogs is. why answer wrong?

i seriously wouldn’t trust site…

directly conflicting answers

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

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -