What is the NodeJS equivalent of Python's if name == "__main__"

Whereas in Python you would use

example.py
if name == "__main__":
    # TODO Your code goes here

in NodeJS you can simply use

example.js
if (require.main === module) {
    // TODO Your code goes here
}

 


Check out similar posts by category: Javascript, NodeJS