javascript - why calling a function within object markup is valid? -
can please explain me how valid? never seen nor expected valid.
https://gist.github.com/martinaglv/0cf3f564d9c31c053da5#file-13-js
function whatdoesitdo(){ var values = []; myblock: { values.push('1'); values.push('2'); break myblock; values.push('3'); } values.push('4'); return values.join(','); }
funny enough, thing (myblock) code label, old tool used give names code blocks. used while coding, like, assembly when using jump instructions , such. used in order use functions 'goto' (don't it's evil!!).
so, in here block called "myblock" inserts elements array. break means code stop executing in block (that's why 2 elements in array there).
later, after '4' inserted, join method turns array string made array's elements, joined "," delimiter. (so becomes "1,2,4") , that's return value
Comments
Post a Comment