-1

a) Is there any difference between the methods bellow (performance wise)?

b) Does this (.find) function iterates over all objects in the array?

c) Is there yet another syntax for this function?

#1 console.log(cres.find(o => o.name === refname));

#2 console.log(cres.find(function(o){return o.name===refname;}));

I'm looking for the most efficient way to find an object by it's property value in a large array. So, implementing a custom function (I.e:BTREE) would be a better approach?

Thx

UPDATE: Besides the "down vote". I've learned that the case in #1 is just a fancy notation for functions (Es6). So basically both cases are the same.

Anyways, It does not explains if the .find function iterates over all objects in the array and if that's the case a custom implementation would be more performatic...

J. Doe
  • 23
  • 4

1 Answers1

1

a) / c) There is no difference, option 1 is just using ES6 syntax. You can checkout the docs here: http://es6-features.org/#ExpressionBodies

b) .find will iterate over the array until it finds a result then it will stop. Reference

zlwaterfield
  • 841
  • 1
  • 9
  • 18