JSFiddle

  • Flatten a mixed type array #2 is the latest revision

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

    var arr = [1, {
        a: 2,
        b: []
    }, '3', [
        [4, 5], 6], 7, 8, [9], null, true, false];
    
    function flatten(arr) {
    
        var ...
  • Circularly Linked List

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

    function Node(element) {
        this.element = element;
        this.next = null;
        this.previous = null;
    }
    
    function LList() {
        this.head = new Node("head");
        this ...
  • Doubly Linked List Practice #5 is the latest revision

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

    function Node(element) {
        this.element = element;
        this.next = null;
        this.previous = null;
    }
    
    function LList() {
        this.head = new Node("head");
        this ...
  • Priority Queue Practice

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

    function Queue() {
        this.dataStore = [];
    }
    
    Queue.prototype.enqueue = function (element) {
        this.dataStore.push(element);
    };
    /*
    Queue.prototype.dequeue = function () {
        return this.dataStore ...
  • Queue Practice

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

    function Queue() {
        this.dataStore = [];
    }
    
    Queue.prototype.enqueue = function (element) {
        this.dataStore.push(element);
    };
    Queue.prototype.dequeue = function () {
        return this.dataStore ...
  • Stack Practice

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

    function Stack() {
        this.dataStore = [];
        this.top = 0;
    }
    
    Stack.prototype.push = function (element) {
        this.dataStore[this.top++] = element;
    }
    
    Stack.prototype.peek ...
  • Background-image problems

    Not always the best solution...

    <div id="target"></div>
    
    <img src="http://placehold.it/300x300/ff0000/000000" />
  • Messing with generators and iterators #3 is the latest revision

    Just playing around...

    function * stringParserGen(str, genFn) {
        var i = 0;
        var char;
        while (i !== str.length) {
            char = str[i++]
            yield * genFn(char)
        }
    
    }
    
    function ...
  • Stopping Event Propagation

    The diff b/w stopPropagation and stopImmediatePropagation

    $('#btn0').on('click', function(e) {
        e.stopPropagation();
        alert(1);
        
    });
    $('#btn0').on('click', function(e) {
        alert(2);
    });
    
    $('#btn1').on('click', function ...
  • Leveraging doc.location & HTML element creation #3 is the latest revision

    Create a fake DOM element to utilize document.location properties

    function parseUrl(url) {
        var aTag = document.createElement('a');
        var locationKeys = _.keys(document.location);
        var obj = {};    
        aTag.href = url;
        _ ...