javascript - What does +obj.length mean in Underscore.js’s each method? -


i trying read underscore.js. i’m going through var each = _.each = _.foreach method.

i understand strict equals (===), not understand +obj.length means.

else if (obj.length === +obj.length) 

here a link code, , here full method:

var each = _.each = _.foreach = function(obj, iterator, context) {     if (obj == null) return;     if (nativeforeach && obj.foreach === nativeforeach) {       obj.foreach(iterator, context);     } else if (obj.length === +obj.length) {       (var = 0, l = obj.length; < l; i++) {         if (iterator.call(context, obj[i], i, obj) === breaker) return;       }     } else {       (var key in obj) {         if (_.has(obj, key)) {           if (iterator.call(context, obj[key], key, obj) === breaker) return;         }       }     }   }; 

this unary + operator. converts argument number. line checks if obj.length number.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -