Is there a JavaScript equivalent of the Python pass statement that does nothing?

前端 未结 9 662
感情败类
感情败类 2021-02-06 20:02

I am looking for a JavaScript equivalent of the Python:

pass statement that does not run the function of the ... notation?

Is the

9条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-06 20:49

    In some cases pass can just be ;

    A real life example can be:

    var j;
    for (j = i + 1; j < binstrN.length && binstrN[j] != 1; j++) {
    }
    let count = j - i;
    

    is same as

    var j;
    for (j = i + 1; j < binstrN.length && binstrN[j] != 1; j++);
    let count = j - i;
    

    Here we are trying to move j to next '1', while i was already at a '1' before it, hence count gives the distance between first two '1's in the string binary string binstrN

提交回复
热议问题