var arr = [{ value: 'a' }, { value: 'a' }, { value: 'b' }, { value: 'b' }];
arr.uniqBy('value'); // [{ value: 'a' }, { value: 'b' }]
Wouldn't be better to do something like this ? var arr = [{ value: 'a' }, { value: 'a' }, { value: 'b' }, { value: 'b' }];
arr.uniqBy(element => element.value); // [{ value: 'a' }, { value: 'b' }]
You have to write a little bit more (I could have used "e" instead of "element", though) but if you do a typo in the name of the property, it can be caught by a linter/compiler, and you don't get the feeling you're relying on Vodoo magic.Are there any advantages to use a string instead of a "static" way of accessing the property ?