The "this" keyword in JS objects

An example showing how to call an object's functions from inside the object.

by kshep92

JavaScript

OBJECT = {

    init: { 

        sayHello: function() { alert("Hello!"); }        
    },
    
    bark: function() {
    
        return(this.init.sayHello)();
    }
};

$(document).ready(function() {
OBJECT.bark();
});