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

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


Python's pass mainly exists because in Python whitespace matters within a block. In Javascript, the equivalent would be putting nothing within the block, i.e. {}.


use //pass like python's pass

like:

if(condition){   //pass}

This is equivalent to leaving the block with nothing in it, but is good for readability reasons.

reference from https://eslint.org/docs/rules/no-empty


python's pass is required for empty blocks.

try:    # somethingexcept Exception:    pass

In javascript you can simply catch an empty block

try {    // some code} catch (e) {    // This here can be empty}