Skip to content

Instantly share code, notes, and snippets.

@michaelficarra
Forked from jashkenas/arrayEq.coffee
Created December 16, 2010 03:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelficarra/742981 to your computer and use it in GitHub Desktop.
Save michaelficarra/742981 to your computer and use it in GitHub Desktop.
arrayEq = (a, b) ->
if a is b
# 0 isnt -0
a isnt 0 or 1/a is 1/b
else if a instanceof Array and b instanceof Array
return no unless a.length is b.length
return no for el, idx in a when not arrayEq el, b[idx]
yes
else
# NaN is NaN
a isnt a and b isnt b
@arrayEqual = (a, b, msg) -> ok arrayEq(a,b), msg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment