Javascript multiple assignment statement

前端 未结 6 1916
小鲜肉
小鲜肉 2021-01-03 10:28

I saw that line in some code

window.a = window.b = a;

How does it work?

Does the following always return true?

win

6条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-03 11:05

    It's the same like:

    window.b=a;
    window.a= window.b;
    

    window.a == a will be true in this case, after the statements above. There are some cases that it will be false, for example: when a is a global variable.

    And one more thing: please find more informative title for your question next time.

提交回复
热议问题