0

Please look at the code snippet below ,Which also having comments(my understandings) wrapped up with the code.Please let me know weather my understanding about the below function are correct or not?

  function MyViewModel() {
        this.DisplayInside = function () { //Is this someting like a public method can be called out side MyViewModel
            console.log("DisplayInside");
        }
        var DisplayInside = function () { ///Is this someting like a private method can be called within MyViewModel
            console.log("DisplayInside");
        }
    }

    MyViewModel.DisplayOutSide = function () { //Is this someting like a public static method
        console.log("DisplayOutSide");
    }

       $(document).ready(function () {

          MyViewModel.DisplayOutSide(); //Call the static method
          var model = new MyViewModel();
          model.DisplayInside(); //Call the function using object
       });

Is there any better approach to implement oops concepts in java Script.

shu
  • 1,938
  • 10
  • 19
  • 1) Yes 2) [Something like](http://stackoverflow.com/q/13418669/1048572) 3) Yes 4) define "better" – Bergi Feb 03 '16 at 06:21
  • Thanks for the reply.by "better" I mean any better approach to implement oops concepts in java script. – shu Feb 03 '16 at 06:28
  • 1
    Use the language how it is designed. Don't try to enforce concepts that you may have learned in other languages. – Felix Kling Feb 03 '16 at 06:44

0 Answers0