Run a function on objet creation | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Run a function on objet creation

I would like to run a function when I create an object. To do so, I created a function that creates an object and then runs the code that follows, which inserts a div in the html code. However, is this the good way to do this? Is there any mean to insert a method in the constructor that will automatically be run when the object is created? Thanks for any answer! https://code.sololearn.com/WDl8C2iFwxZT/?ref=app

18th Aug 2018, 2:13 PM
Kant1
Kant1 - avatar
1 Answer
+ 2
I think your code is correct. 👍
18th Aug 2018, 2:57 PM
Mayur Shedage
Mayur Shedage - avatar