emberjs/ember.js — Issue #293: Ember.empty
Author: edtsech
Created: 2011-12-24 10:32:24+00:00
State: open

IMHO, more expectable behavior can be:

```
test("Ember.empty", function() {
var string = "string", fn = function() {};

equals(true, Ember.empty(null), "for null");
equals(true, Ember.empty(undefined), "for undefined");
equals(true, Ember.empty(""), "for an empty String");
equals(false, Ember.empty(true), "for true");
equals(false, Ember.empty(false), "for false");
equals(false, Ember.empty(string), "for a String");
equals(true, Ember.empty(fn), "for a Function"); // changes here
equals(false, Ember.empty(0), "for 0");
equals(true, Ember.empty([]), "for an empty Array"); // and here
equals(false, Ember.empty({}), "for an empty Object");
});
```

Just for empty arrays and functions also return `true`.

```
Ember.empty = function(obj) {
return obj === null || obj === undefined || obj.length === 0;
};
```