Ember.compare()

compare (v, w) Numberpublic

Defined in packages/ember-runtime/lib/compare.js:40

Compares two javascript values and returns:

  • -1 if the first is smaller than the second,
  • 0 if both are equal,
  • 1 if the first is greater than the second.
 Ember.compare('hello', 'hello');  // 0
 Ember.compare('abc', 'dfg');      // -1
 Ember.compare(2, 1);              // 1

If the types of the two objects are different precedence occurs in the following order, with types earlier in the list considered < types later in the list:

  • undefined
  • null
  • boolean
  • number
  • string
  • array
  • object
  • instance
  • function
  • class
  • date
 Ember.compare('hello', 50);       // 1
 Ember.compare(50, 'hello');       // -1

Parameters:

v Object
First value to compare
w Object
Second value to compare

Returns:

Number
-1 if v < w, 0 if v = w and 1 if v > w.
doc_EmberJs
2016-11-30 16:51:11
Comments
Leave a Comment

Please login to continue.