Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function foo(state) {
- function bar() { return 1; }
- return state ? bar : null;
- }
- foo(false) // null (bar is created but not used)
- foo(true)() // 1 (bar is created and returned)
- function foo(state) {
- return state ? function() { return 1; } : null;
- }
- foo(false) // null (the anonymous function isn't even created)
- foo(true)() // 1 (the anonymous function is created and returned)
Add Comment
Please, Sign In to add comment