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

Will this object always re-call the function?

$
0
0

Here is the first way:

var Objek = {
    node : document.getElementById(known_id),
}

So, when i call Objek.node does this always call the document.getElementById ?

Is this second way better? :

var Objek = (function() {
    var getNode = document.getElementById(known_id);


    return {
        node : getNode
    }
})();

I think this second way is better and wouldn't re-call the document.getElementById when I call Objek.node


Viewing all articles
Browse latest Browse all 3

Trending Articles



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