Passing arguments or accessing properties

I am working on a simple library in javascript. I use one design function that wraps all this. I have private and public properties and functions.

    function myContructor(options){
      this.canvas = options.canvasOptions;
      var taht = this;


      /*Option one*/
      function _createCanvas() {
        var width = that.canvas.width;

      } 

      /*Otion two*/
      function _createCanvas(width) {
        var width = width;
      }

      /*And call it*/

      this.run = function() {
        /*One*/
          _createCanvas();
        /*Two*/
          _createCanvas(that.canvas.width);
      }

    }

Question: when I call a function (public or private), should I pass arguments to it or just let the function access public properties through the that.myPublicPropertyfunction inside and call it without arguments? How do you do it and why?

+4
source share

Source: https://habr.com/ru/post/1620300/


All Articles