diff options
| author | Karl Seamon | 2013-12-04 16:02:28 -0500 | 
|---|---|---|
| committer | Igor Minar | 2013-12-05 16:43:11 -0800 | 
| commit | 785a5fd7c182f39f4ae80d603c0098bc63ce41a4 (patch) | |
| tree | 4e920facdb658233ada317cc18fed8bc05b4c7ab /src | |
| parent | a55c1e79cf8894c2d348d4cf911b28dcc8a6995e (diff) | |
| download | angular.js-785a5fd7c182f39f4ae80d603c0098bc63ce41a4.tar.bz2 | |
chore(Angular.js): Use call and === instead of apply and == in type check functions
Updates isDate et al to use call instead of apply and === instead of ==.
The change to call brings minor performance improvement and === is just
better practice than ==.
http://jsperf.com/call-vs-apply-tostring
Closes #5295
Diffstat (limited to 'src')
| -rw-r--r-- | src/Angular.js | 24 | 
1 files changed, 12 insertions, 12 deletions
| diff --git a/src/Angular.js b/src/Angular.js index 8ee08e48..691ddbc6 100644 --- a/src/Angular.js +++ b/src/Angular.js @@ -393,7 +393,7 @@ function valueFn(value) {return function() {return value;};}   * @param {*} value Reference to check.   * @returns {boolean} True if `value` is undefined.   */ -function isUndefined(value){return typeof value == 'undefined';} +function isUndefined(value){return typeof value === 'undefined';}  /** @@ -407,7 +407,7 @@ function isUndefined(value){return typeof value == 'undefined';}   * @param {*} value Reference to check.   * @returns {boolean} True if `value` is defined.   */ -function isDefined(value){return typeof value != 'undefined';} +function isDefined(value){return typeof value !== 'undefined';}  /** @@ -422,7 +422,7 @@ function isDefined(value){return typeof value != 'undefined';}   * @param {*} value Reference to check.   * @returns {boolean} True if `value` is an `Object` but not `null`.   */ -function isObject(value){return value != null && typeof value == 'object';} +function isObject(value){return value != null && typeof value === 'object';}  /** @@ -436,7 +436,7 @@ function isObject(value){return value != null && typeof value == 'object';}   * @param {*} value Reference to check.   * @returns {boolean} True if `value` is a `String`.   */ -function isString(value){return typeof value == 'string';} +function isString(value){return typeof value === 'string';}  /** @@ -450,7 +450,7 @@ function isString(value){return typeof value == 'string';}   * @param {*} value Reference to check.   * @returns {boolean} True if `value` is a `Number`.   */ -function isNumber(value){return typeof value == 'number';} +function isNumber(value){return typeof value === 'number';}  /** @@ -465,7 +465,7 @@ function isNumber(value){return typeof value == 'number';}   * @returns {boolean} True if `value` is a `Date`.   */  function isDate(value){ -  return toString.apply(value) == '[object Date]'; +  return toString.call(value) === '[object Date]';  } @@ -481,7 +481,7 @@ function isDate(value){   * @returns {boolean} True if `value` is an `Array`.   */  function isArray(value) { -  return toString.apply(value) == '[object Array]'; +  return toString.call(value) === '[object Array]';  } @@ -496,7 +496,7 @@ function isArray(value) {   * @param {*} value Reference to check.   * @returns {boolean} True if `value` is a `Function`.   */ -function isFunction(value){return typeof value == 'function';} +function isFunction(value){return typeof value === 'function';}  /** @@ -507,7 +507,7 @@ function isFunction(value){return typeof value == 'function';}   * @returns {boolean} True if `value` is a `RegExp`.   */  function isRegExp(value) { -  return toString.apply(value) == '[object RegExp]'; +  return toString.call(value) === '[object RegExp]';  } @@ -529,12 +529,12 @@ function isScope(obj) {  function isFile(obj) { -  return toString.apply(obj) === '[object File]'; +  return toString.call(obj) === '[object File]';  }  function isBoolean(value) { -  return typeof value == 'boolean'; +  return typeof value === 'boolean';  } @@ -638,7 +638,7 @@ function includes(array, obj) {  function indexOf(array, obj) {    if (array.indexOf) return array.indexOf(obj); -  for ( var i = 0; i < array.length; i++) { +  for (var i = 0; i < array.length; i++) {      if (obj === array[i]) return i;    }    return -1; | 
