Home  >  Q&A  >  body text

Why do the use of conditional judgments => and >= in JavaScript produce different results?

'use strict';
var arr = ['Bart', 'Lisa', 'Adam'];
var len = arr.length-1;
while(len> =0){
alert('Hello,' arr[len]);
len--;
}//This will pop up normally, and it will stop after popping up after 3 times.

'use strict';
var arr = ['Bart', 'Lisa', 'Adam'];
var len = arr.length-1;
while(len= >0){
alert('Hello,' arr[len]);
len--;
}//After 3 normal pop-ups, many Hellos will pop up, undefined , and then the browser crashes.

Why is this happening?

ringa_leeringa_lee2711 days ago519

reply all(6)I'll reply

  • PHP中文网

    PHP中文网2017-05-19 10:13:47

    I’m on my knees...

    >=是大于等于运算符,=>那是ES6的箭头函数操作符啊,而且你还加了'use strict', the proper native ES6 has started...

    reply
    0
  • phpcn_u1582

    phpcn_u15822017-05-19 10:13:47

    Arrow function

    reply
    0
  • 大家讲道理

    大家讲道理2017-05-19 10:13:47

    >=大于等于 和 <=小于等于
    =>这个是箭头函数 ()=>{}

    reply
    0
  • 仅有的幸福

    仅有的幸福2017-05-19 10:13:47

    The problem with JS parsing, => is the arrow function

    reply
    0
  • 我想大声告诉你

    我想大声告诉你2017-05-19 10:13:47

    Being hit by the perfect hit I mentioned before, it’s hard to tell whether it’s >=, <=, =>, =<

    reply
    0
  • 漂亮男人

    漂亮男人2017-05-19 10:13:47

    There are still so many tricks in js, and I accidentally forget that I am writing code

    reply
    0
  • Cancelreply