9.6: JavaScript Closure – p5.js Tutorial




This video covers JavaScript closures. What is a closure? Why is it useful? The context explored is a closure function that animates a DOM element in the browser.

All examples: https://github.com/shiffman/Video-Lesson-Materials

Contact: https://twitter.com/shiffman

All JavaScript/p5.js videos: https://www.youtube.com/user/shiffman/playlists?shelf_id=14&view=50&sort=dd

Help us caption & translate this video!

http://amara.org/v/Qbta/

Original source


39 responses to “9.6: JavaScript Closure – p5.js Tutorial”

  1. It's not difficult:

    Closure is when a function (child), inside another function (parent), has access to its parent variables.

    The inverse does not apply, a parent function cannot see variables of its children functions.

  2. Awesomest videos on youtube, I draw inspiration from you as a teacher, your method of teaching is similar to mine though you're literally the Epicest person on youtube
    Epic Dude!!! I'm so sorry about one thing though……………………….
    .
    .
    .
    .

    .
    .
    .
    .
    .

    I found your videos too late !!!!

  3. Finally!!! I found a video example of CLOSURE that makes clear sense. Not only does it make clear sense but it's fun to watch. Goofy, silly, insightful, genius, captivating, pure educational entertainment. Highly recommended.

  4. Dan, I love you, I owe you 🙂 These videos are very helpful and colorful.

    I have a question:

    I am trying to synchronize the start time of both timers, so I tried the code below in the setup() function:

    makeTimer(timer1, 1000);
    setTimeout(makeTimer(timer2, 500), 1000);

    the rest of the code is same with the one here. Interestingly program is working but setTimeout() does't seem to work. timer2 still starts 500 milliseconds before timer1.

    Anyone?

Leave a Reply