Multiple variable assignments in one row

前端 未结 4 401
逝去的感伤
逝去的感伤 2020-12-09 07:27

As each programming language is different and my experience with Javascript is on basic level, I would like to know, how multiple variable assignments in one row are evaluat

4条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-09 08:00

    For the most part yes, but consider the following scenario:

    Object.defineProperty(this, "b", { value : 6, writable : false });
    var a, c, d;
    
    a = b = c = d = 5;
    
    console.log(a); // 5
    console.log(b); // 6
    console.log(c); // 5
    console.log(d); // 5
    

提交回复
热议问题