Skip to content

Commit

Permalink
Merge pull request #18447 from beegan/jb/reject-by
Browse files Browse the repository at this point in the history
[DOC] Added example for EmberArray#rejectBy
  • Loading branch information
RobbieTheWagner authored Oct 3, 2019
2 parents 68f64b5 + cce1a04 commit 74c9da1
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions packages/@ember/-internals/runtime/lib/mixins/array.js
Original file line number Diff line number Diff line change
Expand Up @@ -875,9 +875,21 @@ const ArrayMixin = Mixin.create(Enumerable, {
},

/**
Returns an array with the items that do not have truthy values for
key. You can pass an optional second argument with the target value. Otherwise
this will match any property that evaluates to false.
Returns an array with the items that do not have truthy values for the provided key.
You can pass an optional second argument with a target value to reject for the key.
Otherwise this will reject objects where the provided property evaluates to false.
Example Usage:
```javascript
let food = [
{ name: "apple", isFruit: true },
{ name: "carrot", isFruit: false },
{ name: "bread", isFruit: false },
];
food.rejectBy('isFruit'); // [{ name: "carrot", isFruit: false }, { name: "bread", isFruit: false }]
food.rejectBy('name', 'carrot'); // [{ name: "apple", isFruit: true }}, { name: "bread", isFruit: false }]
```
@method rejectBy
@param {String} key the property to test
Expand Down

0 comments on commit 74c9da1

Please sign in to comment.