Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 16619 invoked from network); 26 Aug 2009 05:44:36 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 26 Aug 2009 05:44:36 -0000 Received: (qmail 2815 invoked by uid 500); 26 Aug 2009 05:44:35 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 2730 invoked by uid 500); 26 Aug 2009 05:44:35 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 2715 invoked by uid 99); 26 Aug 2009 05:44:35 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Aug 2009 05:44:35 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of nborwankar@gmail.com designates 209.85.216.180 as permitted sender) Received: from [209.85.216.180] (HELO mail-px0-f180.google.com) (209.85.216.180) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Aug 2009 05:44:26 +0000 Received: by pxi10 with SMTP id 10so6709521pxi.28 for ; Tue, 25 Aug 2009 22:44:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:date :x-google-sender-auth:message-id:subject:from:to:content-type; bh=lS4QKxhDZ2OSLrnci4/QW36JGlBUiZFIn3tSVP9Rs6I=; b=naqq/j5sh3/K6Wsr6n/vGHoJhOHtUOS/yqAGnFghOJM/VhW2tTjAxiyzcHm7xbFjop EYxXIAFvGxBhnTl1IT6aXAy5TYbFex5XSD1zu5k7ILDczHkUX9YtUZRKjkPRlbk76/b+ E+QZj1MCg/SNKpaZVKGxdg4g1YwOIEICZUexE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:date:x-google-sender-auth:message-id:subject :from:to:content-type; b=FX8k4bSaQq+skfYoBk1h+0mhHWKEaxZY2hZheYDHnafQxo6h7dIkdahVmvtXZcUI56 lWaamBBRIwIs+3hK7vhJGF/rN9HzD0QACQ22KYU2UFJ843Ji2uc1fbY7RU0wkDD6Mopf 4uv+82U1477RPfmIV125gZXz5chKfwrGFf9Gg= MIME-Version: 1.0 Sender: nborwankar@gmail.com Received: by 10.140.172.20 with SMTP id u20mr3549136rve.23.1251265441268; Tue, 25 Aug 2009 22:44:01 -0700 (PDT) Date: Tue, 25 Aug 2009 22:44:01 -0700 X-Google-Sender-Auth: e396f78a4a5c665b Message-ID: <921000908252244x6a231c59p7092954f555b34bb@mail.gmail.com> Subject: Doug Crockford's typeOf vs usual js typeof From: Nitin Borwankar To: user@couchdb.apache.org Content-Type: multipart/alternative; boundary=000e0cd296ac2585ac047204f0b0 X-Virus-Checked: Checked by ClamAV on apache.org --000e0cd296ac2585ac047204f0b0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Hi Damien,JChris,JanL et al, As a js newbie I recently hit the WTF? wall when I discovered typeof([1,2,3]) = object rather than the expected array. Doug Crockford suggests a custom typeOf function (note the Cap O) in his remedial javascript http://javascript.crockford.com/remedial.html function typeOf(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; } Given that we may want to deal with arrays and hashes differently in map fucntions, is it possible to add this typeOf fucntion to the standard couch js libs? This would allow this very useful functionality to be accessed in map functions and lucene index functions without having to add these inline or via couchapp. Nitin 37% of all statistics are made up on the spot ------------------------------------------------------------------------------------- Nitin Borwankar nborwankar@gmail.com --000e0cd296ac2585ac047204f0b0--