I want to try object oriented js, and I want to know which approach is better out of the two I am trying and why it is better please explain, If there are any other better approach please suggest me.
// Approch 1
var thisPage;
abc.forgotPassword = {
init: function() {
'use strict';
thisPage.forgotPasswordFunctionality();
},
forgotPasswordFunctionality: function() {
//some code
}
};
$(function() {
thisPage = abc.forgotPassword;
thisPage.init();
});
// Approch 2
abc.forgotPassword = {
init: function() {
'use strict';
abc.forgotPassword.forgotPasswordFunctionality();
},
forgotPasswordFunctionality: function() {
//some code
}
};
$(function() {
abc.forgotPassword.init();
});
thisPage = abc.forgotPassword;).