The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Problem with simple javascript object.

  • This topic is empty.
Viewing 1 post (of 1 total)
  • Author
  • #163929

    I m confused at a point in javascript object concept. I have replicated my issue in a simple object and was wordering that why it is not working. Please have a look at the code.

    var app = {
      initialize : function(){
      bindEvents : function(){
            console.log('bindEvents check');
            window.addEventListener('load', this.onWindowLoad, false);
      onWindowLoad : function(){
          console.log('window is done loading'); 
      someFunction : function(){
          console.log('coming from some Function');  

    this.someFunction(); doesn’t work in ‘onWindowLoad’ function however 'app.someFunction()' works. this.bindEvents(); works in ‘initialize ‘ function, so this works in the first function but not in the last one.

    WHY 'this' isn’t working onWindowLoad function ? Thanks.

Viewing 1 post (of 1 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.