Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

return false the same as return?

Tags:

javascript

Is

return false  

the same as:

return 
like image 288
Phillip Senn Avatar asked Apr 08 '11 14:04

Phillip Senn


People also ask

What does return false mean?

1 : an incorrect report false returns on an income-tax blank. 2 : an untrue return made to a legal process by the officer to whom it was delivered for execution.

What is the difference between return true and return false in Java?

Using return causes your code to short-circuit and stop executing immediately. The first return statement immediately stops execution of our function and causes our function to return true . The code on line three: return false; is never executed.

What is the use of return false?

You use return false to prevent something from happening. So if you have a script running on submit then return false will prevent the submit from working.

What is return false and true?

The return True ends the function's execution and returns the boolean True. Similarly return False ends the function's execution and returns the boolean False. If you don't have a return statement then when the function exits it returns None.


1 Answers

No.

var i = (function() { return; })();

i === undefined which means that i == false && i == '' && i == null && i == 0 && !i

var j = (function() { return false; })();

j === false which means that j == false && j == '' && j == null && j == 0 && !j

Weak operators in JS make it seem like the might return the same thing, but they return objects of different types.

like image 195
Bob Fincheimer Avatar answered Oct 16 '22 23:10

Bob Fincheimer