While developing stuff with Ember.js I stumbled upon some very nice and handy functions which are built in. This post lists some of them and describes in a short what they are used for.
当用Ember.js开发时,我发现了一些优美且实用的函数。本文列出了它们,并简短地说明了用法。
The following functions are defined in packages/ember-runtime/lib/core.js and packages/ember-metal/lib/utils.js respectively.
Returns true if argument is null or undefined.
1 | Ember.none(); // true |
This utility function constrains the rules on Ember.none by returning false for empty string and empty arrays.
1 | Ember.empty(); // true |
Use this to check if a value is an array. This method also returns true for array-like objects, like the ones implementing Ember.Array.
1 | Ember.isArray(); // false |
More useful String functions
There are some more functionalities for converting between different String notations: camelize(), decamelize(), dasherize(), underscore()
Posted by Clemens Müller Mar 8th, 2012
Ember.js