0

I have a large object, and I mean large with multiple keys and values. Out of the cases below, which would be most performant and less memory intensive, or does it matter?

Global Variable Here

var sample = {"keya":"value-a-is-a-huge-nested-map","keyb":"valueb",...many-other-key-value-pairs }

CASE A

doSomething(sample.keya);
function doSomething(testobject) {
    // 1. do manipulation on it to return a result
}

CASE B

doSomething(a.keya);
function doSomething(key) {
    // 1. extract the specific key from "sample"
    // 2. do a lookup on the value from "sample"
    // 3. do manipulation on it to return a result
}

Now imagine the same case above, but replace the function calls with $scope.$emit and $scope.$on instead of just plain function calls. Is it safe to assume that using Case 2 is better because your not "emitting" over the value of a large object?

Rolando
  • 58,640
  • 98
  • 266
  • 407

0 Answers0