Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Closures and Scoping */
- !function(window) {
- var body = window.getElementsByTagName('body')[0];
- console.log(body);
- }(document);
- /*
- Q: What would you expect the value of body to be?
- A: Body will be the actual body. Although getElementsByTagName is not a valid window
- document, we have changed the value of window to be document based on the closure.
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement