Benefits of declaring variable type through assignment in JavaScript -


in javascript, there benefit in assigning temporary value newly declared variable? example...

var = 0,     b = '';  // somewhere else = 5; b = 'goodbye'; 

vs

var a, b;  // somewhere else     = 5; b = 'goodbye'; 

i'm aware assigning variable on declaration set type. in javascript, can changed assigning value of different type, doesn't protect in way.

what advantages/disadvantages of above?

i believe advantage is: order in code. you'll know right beginning of code type var.

the disadvantage more code lines , size of file.


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -