SubhanUllah Posted October 4, 2022 Report Share Posted October 4, 2022 Both do exactly the same if and only if value===undefined. The following example demonstrates the differences. function f1() { } // no return statement returns undefined. function f2() { return; } // returns undefined too. The undefined is implicit here. function f3() { return undefined; } // explicitly returns undefined function f4() { return 1; } // returns 1. console.log('f1() === ' + f1()); // prints: f1() === undefined console.log('f2() === ' + f2()); // prints: f2() === undefined console.log('f3() === ' + f3()); // prints: f3() === undefined console.log('f4() === ' + f4()); // prints: f4() === 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.