What is the order of precedence for modulus in Javascript?

后端 未结 3 530
栀梦
栀梦 2021-01-29 10:55

If I have the following code

var num = 15 % 2 + 6 * 4;

for example... I\'d like to know what the output will be, specifically I would like to

3条回答
  •  盖世英雄少女心
    2021-01-29 11:32

    Basically you going left to right but you're doing plus first, then multiply, then divide, and the remainder stuff is divide. So

     var num = 15 % 2 + 6 * 4;
    

    is basically 15 % 2 = 1

提交回复
热议问题