Essentially, no: you’re performing a list lookup by value, not by index, so it will always be a linear traversal.
An improvement would be to use find
instead of filter
:
var result = map.find(function(obj){return obj.get('id') === 4;});
Essentially, no: you’re performing a list lookup by value, not by index, so it will always be a linear traversal.
An improvement would be to use find
instead of filter
:
var result = map.find(function(obj){return obj.get('id') === 4;});