Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there anything special about the init function in JavaScript objects?

Tags:

javascript

In a lot of code, it's very common to see an init function be declared, like so:

var someObject = {

    // What is this for?
    init: function () {
        // Call here.
    }
};

Are there anything particularly special about the init function that I should know?

like image 221
Sal Rahman Avatar asked Jul 17 '11 22:07

Sal Rahman


1 Answers

For some frameworks perhaps (though prototype and backbone use initialize instead), but there is nothing special about the init functions in plain old javascript

like image 171
Pablo Fernandez Avatar answered Oct 03 '22 18:10

Pablo Fernandez