-  [WT]  [PS]  [Home] [Manage]

[Return]
Posting mode: Reply
  1.   (reply to 4730)
  2. (for post and file deletion)
/pr/ - Programming
  • Supported file types are: C, CSS, DOC, DOCX, GIF, H, JAVA, JPG, PDF, PNG, SVG, SWF, TXT, WEBM
  • Maximum file size allowed is 10000 KB.
  • Images greater than 200x200 pixels will be thumbnailed.
  • Currently 389 unique user posts. View catalog

  • Blotter updated: 2011-01-12 Show/Hide Show All

There's a new /777/ up, it's /gardening/ Check it out. Suggest new /777/s here.

Movies & TV 24/7 via Channel7: Web Player, .m3u file. Music via Radio7: Web Player, .m3u file.

WebM is now available sitewide! Please check this thread for more info.

Closures & Callbacks(javascript) Boy Next Door 15/05/04(Mon)13:27 No. 4730

Can someone please explain these two concepts to me? I've been going through different books & youtube videos and I think I got the gist of them, but I'd like an explanation from others. I'm more confused how these concepts tie in with asynchronous vs. synchronous.


>>
Nattajerk 15/05/19(Tue)23:33 No. 4732

A closure can be thought of as a function within a function, which has access to variables in its scope. That's basically all it is, there are some technical things about it but you need not concern yourself with them just yet.

A callback is passing a function to another function as a variable. Wikipedia probably describes it best,

http://pastebin.com/6rXWAQEd

in this, someAction requests a function as a parameter. what this means is you can insert your own compatible function and it will be executed within the someAction function, rather than evaluated it if it were just asking for a standard variable.




Delete post []
Password  
Report post
Reason