Skip to main content
added 128 characters in body
Source Link
Kevin Boucher
  • 16.6k
  • 3
  • 49
  • 56

Is it possible to call another prototype method inside a prototype method ? Like below.

jQuery(document).ready(function ($) {
    let gui = new GUI();
    let App = new App(gui);
});

var App = function(gui) {
    this.gui = gui;
    this.init();
    return this;
};

App.prototype.init = function() {
    this.gui.test();
};

var GUI = function() {
    return this;
};

GUI.prototype.test = function() {
    console.log("Test");
};
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

I would like to call something like this.

Best regards and thx for ur help

Is it possible to call another prototype method inside a prototype method ? Like below.

jQuery(document).ready(function ($) {
    let gui = new GUI();
    let App = new App(gui);
});

var App = function(gui) {
    this.gui = gui;
    this.init();
    return this;
};

App.prototype.init = function() {
    this.gui.test();
};

var GUI = function() {
    return this;
};

GUI.prototype.test = function() {
    console.log("Test");
};

I would like to call something like this.

Best regards and thx for ur help

Is it possible to call another prototype method inside a prototype method ? Like below.

jQuery(document).ready(function ($) {
    let gui = new GUI();
    let App = new App(gui);
});

var App = function(gui) {
    this.gui = gui;
    this.init();
    return this;
};

App.prototype.init = function() {
    this.gui.test();
};

var GUI = function() {
    return this;
};

GUI.prototype.test = function() {
    console.log("Test");
};
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

I would like to call something like this.

Best regards and thx for ur help

Source Link
Benimo
  • 167
  • 1
  • 1
  • 7

Calling prototype method from another object

Is it possible to call another prototype method inside a prototype method ? Like below.

jQuery(document).ready(function ($) {
    let gui = new GUI();
    let App = new App(gui);
});

var App = function(gui) {
    this.gui = gui;
    this.init();
    return this;
};

App.prototype.init = function() {
    this.gui.test();
};

var GUI = function() {
    return this;
};

GUI.prototype.test = function() {
    console.log("Test");
};

I would like to call something like this.

Best regards and thx for ur help