Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I am looking for a JavaScript equivalent of the Python:

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

Is there such a thing in JavaScript?

like image 393
guagay_wk Avatar asked Oct 09 '22 15:10

guagay_wk


People also ask

What can I use instead of pass in Python?

With Python >= 3.0, you should use ... (Ellipsis) instead of pass to indicate "finish later" blocks.

When the python pass statement is executed nothing happens?

Python pass Statement The pass statement is used as a placeholder for future code. When the pass statement is executed, nothing happens, but you avoid getting an error when empty code is not allowed. Empty code is not allowed in loops, function definitions, class definitions, or in if statements.

Is pass an empty statement in Python?

In python, we can write an empty function or statements by using the 'pass” statement. Writing a pass statement does nothing and is simply used to avoid compile errors while writing an empty function. Above code statements are little different than other popular programming languages like C,C++ or Java.

What is passin Python?

What is pass statement in Python? In Python programming, the pass statement is a null statement. The difference between a comment and a pass statement in Python is that while the interpreter ignores a comment entirely, pass is not ignored. However, nothing happens when the pass is executed.


2 Answers

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. {}.

like image 207
jakevdp Avatar answered Oct 12 '22 03:10

jakevdp


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

like image 60
Sirius Avatar answered Oct 12 '22 03:10

Sirius