advanced

concepts

class overview

  • Homework Questions
  • Closures
  • Delete
  • Homework Review

closures

  • Closures are functions that have references to "free" variables
  • They remember the context they are created in
  • Closures are used to simulate "private" variables

 function closureFunction() {
     var message = "I'm from a closure!";
     function logMessage() {
          console.log(message);
     }
     return logMessage;
 }

MDN Closure Documentation

delete

  • The 'delete' keyword in JavaScript removes variables or properties.
  • Variables declared with the var keyword cannot be deleted.
 var x = 2;
 delete x;
 //false, x is not deleted

 y = 3;
 delete y;
 //true, y is deleted

 var obj = { y : 5 };
 delete obj.y;
 //true, obj.y is deleted

Understanding delete

cool js thing for the day

jsConf Videos
All (most?) of the presentations from jsConf worldwide
Made with Slides.com