redho home | products | services
Web Design Forums

Web Design Forums  


Web Hosting, Web Design, Software and Web Development Forums  
 FAQFAQ   MemberlistArchive  Log inLog in   RegisterRegister 
         

prototype js



 
Post new topic   Reply to topic    Web Design Forums -> PHP programming forum
View previous topic :: View next topic  
Author Message
Poolkop



Joined: 01 Jun 2006
Posts: 123
Anyone familiar with Prototype.js?
I'm trying to unravel some of these secrets, mostly how to figure out what 'this' means in the different contexts...
What is a closure? it is a function that returns a function that encloses a reference to it's object?
  Reply with quote


kadamat



Joined: 01 Jun 2006
Posts: 88
It is a function with locally scoped variables that returns a function. When the function that gets returned is called it has access to those locally scoped variables - but nothing else does.
  Reply with quote
Poolkop



Joined: 01 Jun 2006
Posts: 123
Thanks kadamat!
  Reply with quote
kadamat



Joined: 01 Jun 2006
Posts: 88
Poolkop, If you call the outside function again, the locally scoped variables are created anew, and the returned function has access to only those versions of those variables.
http://js.edea.se/events_and_closures.html might be helpful.
  Reply with quote
Poolkop



Joined: 01 Jun 2006
Posts: 123
what's with the lack of the < symbol in the printVal() ?
  Reply with quote
kadamat



Joined: 01 Jun 2006
Posts: 88
No idea. Maybe an error? I wouldn't play with innerHTML myself
  Reply with quote
Poolkop



Joined: 01 Jun 2006
Posts: 123
Why would you write a function that takes 1 argument that is an object with the arguments attached to it?
Ie: function foo(args) { this.title = args.title; this.author = args.author; } ?
  Reply with quote
kadamat



Joined: 01 Jun 2006
Posts: 88
Because some arguments may be optional.
Or because you are using the object in other places
  Reply with quote
Page 1 of 1
Post new topic   Reply to topic    Web Design Forums -> PHP programming forum


Dubai Forums - Expat Help | Vegan Chat | Java Programming | Free 3D tutorials and 3d textures | Paris Forum | EU Forum
Free Dubai Classifieds | Free London Classifieds | Jobs in London

High Quality, Custom 3d animation and Web Design solutions Royal Quality Web Hosting Services Vegetarian and Animal Rights news

Powered by phpBB © 2001, 2005 phpBB Group