Advertisement
Guest User

Untitled

a guest
Jul 26th, 2016
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. /* Closures and Scoping */
  2.  
  3. !function(window) {
  4. var body = window.getElementsByTagName('body')[0];
  5.  
  6. console.log(body);
  7. }(document);
  8.  
  9. /*
  10. Q: What would you expect the value of body to be?
  11.  
  12. A: Body will be the actual body. Although getElementsByTagName is not a valid window
  13. document, we have changed the value of window to be document based on the closure.
  14. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement