Joshua Soileau
Joshua Soileau

Reputation: 3015

Javascript init() function isn't being called automatically

I'm using this syntax for my class creation (jQuery):

$.myClass = function() {}
$.myClass.prototype = {
    init: function() {
        console.log('initializing');
    },
    someFunc: function() = {
        console.log('some function is being called');
    }
}

When I call

var myClassObj = new $.myClass();

My init() function isn't being called, I have to call it manually. How do I edit my class's default initialization function instead of creating a separate one?

Upvotes: 0

Views: 2091

Answers (1)

Rohan
Rohan

Reputation: 3332

You missed this -

$.myClass = function() 
    {
      this.init();
    }

Upvotes: 1

Related Questions