Pārlūkot izejas kodu

Better isArray implementation via

62efd014fc (comments)

Thanks Nikita!
tags/0.2.3
Jan Lehnardt pirms 16 gadiem
vecāks
revīzija
195fa9e255
1 mainītis faili ar 2 papildinājumiem un 21 dzēšanām
  1. +2
    -21
      mustache.js

+ 2
- 21
mustache.js Parādīt failu

@@ -238,30 +238,11 @@ var Mustache = function() {
}, },


is_object: function(a) { is_object: function(a) {
return this.typeOf(a) === "object";
return a && typeof a == "object";
}, },


is_array: function(a) { is_array: function(a) {
return this.typeOf(a) === "array";
},

/*
Thanks Doug Crockford http://javascript.crockford.com/remedial.html
*/
typeOf: function(value) {
var s = typeof value;
if(s === "object") {
if(value) {
if(typeof value.length === "number" &&
!(value.propertyIsEnumerable("length")) &&
typeof value.splice === "function") {
s = "array";
}
} else {
s = "null";
}
}
return s;
return Object.prototype.toString.call(a) === '[object Array]';
}, },


/* /*


Notiek ielāde…
Atcelt
Saglabāt