From 195fa9e255aaf9b9c3cee7fa1b844e76e043412a Mon Sep 17 00:00:00 2001 From: Jan Lehnardt Date: Fri, 19 Feb 2010 15:18:56 -0800 Subject: [PATCH] Better isArray implementation via http://github.com/janl/mustache.js/commit/62efd014fcfa0aa11c2a70b2dce8d6d48378d074#comments Thanks Nikita! --- mustache.js | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/mustache.js b/mustache.js index e23103b..de061bc 100644 --- a/mustache.js +++ b/mustache.js @@ -238,30 +238,11 @@ var Mustache = function() { }, is_object: function(a) { - return this.typeOf(a) === "object"; + return a && typeof a == "object"; }, 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]'; }, /*