Answer the question
In order to leave comments, you need to log in
What is the difference between these options?
What is the difference between these options:
andvar tempScrollTop, currentScrollTop = 0;
var tempScrollTop = 0;
var currentScrollTop = 0;
Answer the question
In order to leave comments, you need to log in
The first one is bad because two variables are declared on the same line.
The second is bad because two var
.
I would like this (now they will downvote .. Oh, no, you can’t downvote here :)
var tempScrollTop
, currentScrollTop = 0
;
tempScrollTop
remains uninitialized, its value is undefined
, and in the 2nd variant it is given the initial value 0
.
in that the normal, supported, less dangerous option is the second, and the first should be used only when there are no values for variables, such as:var tempScrollTop, currentScrollTop;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question