documentcloud/underscore — pull request #526 by chrisleishman (2012-03-27 05:06:46+00:00)
Title: Add _.slice(source, *keys)

Return a clone of the source with only the properties named in *keys
(either stings or arrays containing strings).

Especially useful for avoiding mass-assignment vulnerabilities.

```
_.slice({name : 'moe', age: 50, userid : 'moe1'}, 'name', 'age');
=> {name : 'moe', age : 50}
_.slice({name : 'moe', age: 50, userid : 'moe1'}, ['name', 'age']);
=> {name : 'moe', age : 50}
```

This is another alternative to #523 and #520, using a different name for the method; so the different approaches can be compared. Feel free to reject (personally, I still prefer `_.restrict`).