I have js file myScript.js
(function () {
'use strict';
if (!window.myObj) {
window.myObj= {};
}
var myObj= window.myObj;
myObj = {
home: function () {
console.log('hi from home');
},
details: function(){
console.log('hi from details');
}
})();
inside view page I'm trying to access home method on myObj object
<script>
$(document).ready(function () {
myObj.home();
});
</script>
but I'm getting
uncaught TypeError: myObj.home is not a function(…)
myScript.js is loaded and no console error on loading page.

myObjisn't closed...