Quantcast
Channel: User Alexis Abril - Stack Overflow
Viewing all articles
Browse latest Browse all 43

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

$
0
0

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 all articles
Browse latest Browse all 43

Trending Articles



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