Back to Homepage Share on Facebook View my LinkedIn Profile

UX Development Resource


Javascript Toggling an Element Block or Inine

This content can be toggled.

Photo Slider
Left Position: 0


Create a function then a second function that inherits from the original function.

/* Class Person. */
function Person(name) { = name;
Person.prototype.getName = function() {
var reader = new Person('John Smith'); reader.getName();
var reader2 = new Person('Jack Tripper'); reader2.getName();

Polymorphism JavaScripting

JavaScript Closures

Two one sentence summaries:

  • a closure is the local variables for a function - kept alive after the function has returned, or
  • a closure is a stack-frame which is not deallocated when the function returns. (as if a 'stack-frame' were malloc'ed instead of being on the stack!)

function sayHello2(name) {
   var text = 'Hello ' + name; // local variable
   var sayAlert = function() { alert(text); }
   return sayAlert;

Closure results here …