JSFiddle

  • MVVM

    Implementation of MVVM in JavaScript

    (function() {
    
      "use strict";
    
      var view, viewModel, valueTemplate;
    
      valueTemplate = {
        configurable: false,
        enumerable: true,
        get: function() {
          return this._value;
        },
        set: function(val ...
  • MVC

    Implementation of MVC in JavaScript

    (function() {
    
    	"use strict";
    
      var model, view, controller;
    
    	// this is simply data and behavior. In this 
      // case a single property is ...
  • Bifurcation Diagram

    Chaos in JavaScript

    (function () {
        var c = document.getElementById("c"),
            ctx = c.getContext("2d"),
            w = c.width,
            h = c.height,
            st = 2 / w,
            imgArray ...
  • Plasma #16 is the latest revision

    TypeScript goes plasma

    const screenHeight: number = 200;
    const screenWidth: number = 320; 
    
    var requestAnimFrame = (callback) => 
         		  window.requestAnimationFrame(callback)       || 
                  window.webkitRequestAnimationFrame(callback) || 
                  window.mozRequestAnimationFrame(callback ...
  • What is This?

    Demonstration of This

    var obj1 = {
        foo: "this",
        bar: function () {
            return this.foo;
        }
    }, obj2 = {
        foo: "that",
        bar: obj1.bar
    },
    obj3 = {
        foo: "the other"
    };
    
    obj3 ...
  • Immediately Invoked Function Expression #56 is the latest revision

    Example of IIFE.

    (function (myDiv, setVal) {
        var x = 10;
        for (; x; x -= 1) {
            (function (y) {
                setTimeout(function () {
                	setVal(myDiv, y);
            	}, (10 - x) * 1000 ...
  • Closure Example #4 is the latest revision

    How closures and captures work

    for (x = 0; x < 10; x += 1) {
        setTimeout(function () {
            console.log(x);
        }, 0);
    }
    
    
  • Static properties #3 is the latest revision

    No-Library (pure JS), HTML, CSS, JavaScript

    function foo() {}
    foo.bar = "this";
    var bar = new foo();
    console.log(bar.bar);
    console.log(foo.bar);
  • Numeric conversion #2 is the latest revision

    Showing === test

     function isTwo(test) {
         var testNumber = Number(test);
         return testNumber === 2;
     }
    
     console.log(isTwo("two")); // false
     console.log(isTwo("2")); // true ...
  • Whack Whack Pattern #8 is the latest revision

    Converting values to Boolean

    function test(value) {
        return !!value;
    }
    
    console.log(test(""));
    console.log(test("something"));
    console.log(test("0"));
    console.log(test(0 ...