Quantcast
Viewing latest article 32
Browse Latest Browse All 43

Answer by Alexis Abril for How can I refer to a parent from a child?

I'd also move showAlert onto the prototype, so you're not creating a new function in memory every time you instantiate ParentControl.

var ParentControl = function() {    this.childControl = new ChildControl(this);};ParentControl.prototype.showAlert = function() {  console.log('hello');};var ChildControl = function(parent) {  parent.showAlert();};var parentControl = new ParentControl();

Viewing latest article 32
Browse Latest Browse All 43

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>