| Author |
what is "function" here means ?
|
Nakata kokuyo
Ranch Hand
Joined: Apr 13, 2005
Posts: 437
|
|
hi, good day , can expert here explain what is "function" means here? how to use it ? and when should we use it ? can someone give better example ? thank you for guidance
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56177
|
|
Functions are 1st-class objects in Javascript and as such can be declared as literals. The syntax you are seeing here is creating a function literal and assigning it to the onreadystate property of an object. This construct is also sometimes termed a "closure". [ August 02, 2006: Message edited by: Bear Bibeault ]
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Nakata kokuyo
Ranch Hand
Joined: Apr 13, 2005
Posts: 437
|
|
|
bear, i still can't understand it ? do you mind to give me better example?
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
|
|
Basic example of extending objects with prototype: Eric
|
 |
Nakata kokuyo
Ranch Hand
Joined: Apr 13, 2005
Posts: 437
|
|
great , eric .. thanks for useful sample , meaning i can assume it as class in java ? something like following for this sample message.informUser = function(){ this.text = null;} as following prototype ?
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56177
|
|
Not really. Take the following example: this is similar to: In the first example no separate, named function is created -- an unnamed function is created using a function literal. In the second, a reference to a named function is stored. In either example, a reference to a function that says "hi!" is stored int he someProperty property of someObject. (There is a difference between the 2 examples regarding how variables are scoped, but that's a nuance that might just be confusing at this point).
|
 |
Nakata kokuyo
Ranch Hand
Joined: Apr 13, 2005
Posts: 437
|
|
thanks for guidance , bear , i'm understand it better now
|
 |
 |
|
|
subject: what is "function" here means ?
|
|
|