onload « scope « Javascript Data Type Q&A

Home
Javascript Data Type Q&A
1.Array
2.Clojure
3.date
4.decimal
5.function
6.global
7.loop
8.math
9.number
10.object
11.Regular Expression
12.scope
13.String
14.Var
15.variable
Javascript Data Type Q&A » scope » onload 

1. JavaScript: How is "function onload() {}" different from "onload = function() {}"?    stackoverflow.com

In the answers to this question, we read that function f() {} defines the name locally, while [var] f = function() {} defines it globally. That makes perfect sense to ...

2. javascript window.onload scope    stackoverflow.com

Can someone explain why the alert returns "undefined" instead of "hello"?

window.onload = function() {  
    var a = 'hello';  
    alert(window.a);  
}
...

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.