Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 785a5fd

Browse files
kseamonIgorMinar
authored andcommitted
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
1 parent a55c1e7 commit 785a5fd

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/Angular.js

+12-12
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ function valueFn(value) {return function() {return value;};}
393393
* @param {*} value Reference to check.
394394
* @returns {boolean} True if `value` is undefined.
395395
*/
396-
function isUndefined(value){return typeof value == 'undefined';}
396+
function isUndefined(value){return typeof value === 'undefined';}
397397

398398

399399
/**
@@ -407,7 +407,7 @@ function isUndefined(value){return typeof value == 'undefined';}
407407
* @param {*} value Reference to check.
408408
* @returns {boolean} True if `value` is defined.
409409
*/
410-
function isDefined(value){return typeof value != 'undefined';}
410+
function isDefined(value){return typeof value !== 'undefined';}
411411

412412

413413
/**
@@ -422,7 +422,7 @@ function isDefined(value){return typeof value != 'undefined';}
422422
* @param {*} value Reference to check.
423423
* @returns {boolean} True if `value` is an `Object` but not `null`.
424424
*/
425-
function isObject(value){return value != null && typeof value == 'object';}
425+
function isObject(value){return value != null && typeof value === 'object';}
426426

427427

428428
/**
@@ -436,7 +436,7 @@ function isObject(value){return value != null && typeof value == 'object';}
436436
* @param {*} value Reference to check.
437437
* @returns {boolean} True if `value` is a `String`.
438438
*/
439-
function isString(value){return typeof value == 'string';}
439+
function isString(value){return typeof value === 'string';}
440440

441441

442442
/**
@@ -450,7 +450,7 @@ function isString(value){return typeof value == 'string';}
450450
* @param {*} value Reference to check.
451451
* @returns {boolean} True if `value` is a `Number`.
452452
*/
453-
function isNumber(value){return typeof value == 'number';}
453+
function isNumber(value){return typeof value === 'number';}
454454

455455

456456
/**
@@ -465,7 +465,7 @@ function isNumber(value){return typeof value == 'number';}
465465
* @returns {boolean} True if `value` is a `Date`.
466466
*/
467467
function isDate(value){
468-
return toString.apply(value) == '[object Date]';
468+
return toString.call(value) === '[object Date]';
469469
}
470470

471471

@@ -481,7 +481,7 @@ function isDate(value){
481481
* @returns {boolean} True if `value` is an `Array`.
482482
*/
483483
function isArray(value) {
484-
return toString.apply(value) == '[object Array]';
484+
return toString.call(value) === '[object Array]';
485485
}
486486

487487

@@ -496,7 +496,7 @@ function isArray(value) {
496496
* @param {*} value Reference to check.
497497
* @returns {boolean} True if `value` is a `Function`.
498498
*/
499-
function isFunction(value){return typeof value == 'function';}
499+
function isFunction(value){return typeof value === 'function';}
500500

501501

502502
/**
@@ -507,7 +507,7 @@ function isFunction(value){return typeof value == 'function';}
507507
* @returns {boolean} True if `value` is a `RegExp`.
508508
*/
509509
function isRegExp(value) {
510-
return toString.apply(value) == '[object RegExp]';
510+
return toString.call(value) === '[object RegExp]';
511511
}
512512

513513

@@ -529,12 +529,12 @@ function isScope(obj) {
529529

530530

531531
function isFile(obj) {
532-
return toString.apply(obj) === '[object File]';
532+
return toString.call(obj) === '[object File]';
533533
}
534534

535535

536536
function isBoolean(value) {
537-
return typeof value == 'boolean';
537+
return typeof value === 'boolean';
538538
}
539539

540540

@@ -638,7 +638,7 @@ function includes(array, obj) {
638638
function indexOf(array, obj) {
639639
if (array.indexOf) return array.indexOf(obj);
640640

641-
for ( var i = 0; i < array.length; i++) {
641+
for (var i = 0; i < array.length; i++) {
642642
if (obj === array[i]) return i;
643643
}
644644
return -1;

0 commit comments

Comments
 (0)