Guest User

Untitled

a guest
Dec 14th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. (function one(){
  2. var foo = (function two(){
  3. if(true){
  4. return true; //all good
  5. }else{
  6. //how can we break function one here?
  7. })();
  8. //extra statements only executed if foo is true
  9. })();
  10.  
  11. ;(function() {
  12. var foo = (function() { return true })()
  13. if (!foo) return;
  14. console.log('reached because foo was true')
  15. })()
  16.  
  17. ;(function() {
  18. try {
  19. ;(function() {
  20. var foo = (function() { throw new Error('fail') })()
  21. /* only reached if an error wasn't thrown */
  22. })()
  23. }
  24. catch (error) {
  25. console.log('Something went wrong: ' + error)
  26. }
  27. })()
  28.  
  29. reached because foo was true
  30. Something went wrong: Error: fail
Add Comment
Please, Sign In to add comment