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

前端 未结 9 661
感情败类
感情败类 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:42

    I know this is a very old answer but i guess that is also possible to do something like this.
    You can declare a constant that contains a string.

    const pass = 'pass';
    
    if (condition) {
       pass
    } else {
       console.log('hi!')
    }
    

    However note also that this may be a better option.

    if (condition) {}
    else {
        console.log('cool!')
    }
    

提交回复
热议问题