documentcloud/underscore — Issue #340: Feature request: isType function
Author: dulakian
Created: 2011-10-19 12:18:43+00:00
State: open

I find myself mixing in this function on virtually every project (coffeescript):

isType = (obj, types) ->
c = obj.constructor
if types.constructor is Array
return c in types
else
return c is types

Any chance to get something like this included by default? I don't mind using _.mixin myself to add it, but it is handy for checking an object against multiple types.