Since it is possible to do:
var x = 'foo', y = 'foo';
Would this also be possible?
var x, y = 'foo';
I tried it, however x becomes undefined.
I know this may seem like a silly or redundant question, but if I'm curious about something, why not ask? Also you will probably wonder why I would need two variables equal to the same thing in scope. That is not the point of the question. I'm just curious.
var is function scoped. let does not allow to redeclare variables. var allows to redeclare variables.
The var statement declares a function-scoped or globally-scoped variable, optionally initializing it to a value.
Var[X+Y] = Var[X] + Var[Y] + 2∙Cov[X,Y] .
var is a keyword, it is used to declare an implicit type variable, that specifies the type of a variable based on initial value.
Not sure if this is what you're asking, but if you mean "Can I assign two variables to the same literal in one line without typing the literal twice?" then the answer is yes:
var x = 10, y = x;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With