assign multiple variables to the same value in Javascript

前端 未结 5 2016
Happy的楠姐
Happy的楠姐 2020-11-30 18:40

I have initialized several variables in the global scope in a JavaScript file:

var moveUp, moveDown, moveLeft, moveRight;
var mouseDown, touchDown;
         


        
5条回答
  •  死守一世寂寞
    2020-11-30 18:58

    Nothing stops you from doing

    moveUp = moveDown = moveLeft = moveRight = mouseDown = touchDown = false;
    

    Check this example

    var a, b, c;
    a = b = c = 10;
    console.log(a + b + c)

提交回复
热议问题