emberjs/ember.js — pull request #1044 by devinus (2012-06-20 19:13:22+00:00)
Title: Add two new core methods to allow invoking possibly unknown methods on objects

Rationale:

This is such a common idiom throughout Ember and my Ember apps:

```js
var foo = get(this, 'foo');
if (foo && typeof foo.bar === 'function') {
foo.bar();
}
```

...that I think it makes perfect sense to solidify the paradigm in Ember, especially when the code is less than 10 lines long total. Great code exposing good patterns in small chunks feels like the new thing Ember is trying to achieve. For instance: `Ember.Evented`.

I ask for naming suggestions as I don't particularly like `tryToPerform`.

Two possible alternatives already suggested include:

- `methodExists` / `invokeIfExists`
- `canInvoke` / `tryInvoke`