0
Is it safe to leave a return expression without arguments in JavaScript?
I am learning python at the moment and the author of the book use return expression without arguments.
1 Antwort
+ 6
(javascript)
if you don't expect any return value , it's safe, but be careful with long functions body, it can cause confuse.
When someone use return without arguments that means the function ends.
Quickly example:
function someFunc(data){
if(!data) return;
//Do something
}
If data doesn't exist, ends the function. As you can see, it's useful to keep the code clean and understandable, you don't need nested if(){ ... } else{ ...}