How do I compute a variable in JavaScript if and only if it is used?

后端 未结 0 1246
挽巷
挽巷 2021-02-15 04:39

This is what I\'m doing right now.

var foo = function() {
  var x = someComplicatedComputationThatMayTakeMoreTime();
  this.foo = function() { return x; };
  ret         


        
相关标签:
回答
  • 消灭零回复
提交回复
热议问题