Quantcast
Channel: Will this object always re-call the function? - Stack Overflow
Viewing all articles
Browse latest Browse all 3

Answer by Radek Pech for Will this object always re-call the function?

$
0
0

In both cases getElementById() is called only once (when you create the object, not when you use objek.node).

In first case ONLY getElementById() is called and value assigned into new object...

...while in second case first your function is called, then getNode variable is created, then getElementById() is called and result is assigned to variable and at last new object is created with given property.

So actually first case is both faster to execute and better to understand by developers.


Viewing all articles
Browse latest Browse all 3

Trending Articles



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