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;
 }

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

cool js thing for the day

All (most?) of the presentations from jsConf worldwide

AJS Lecture 14: Advanced Concepts

By Ryan Lewis

AJS Lecture 14: Advanced Concepts

  • 508