How can I exit from a javascript function? [duplicate]
The return exits the function returning undefined. The exit statement doesn’t exist in javascript. The break statement allows you to exit a loop, not a function. For example: This also works with the for and the switch loops.