-
Notifications
You must be signed in to change notification settings - Fork 2k
Closed
Description
In the following code, how is it possible to get the length of wtf.bar ?
foo = (a, b, c) ->
bar = (a, b, c) =>
class Wtf
foo: (a, b, c) ->
bar: (a, b, c) =>
wtf = new Wtf()
results =
[
foo.length
bar.length
wtf.foo.length
wtf.bar.length
]
console.log results
# Ouputs: [ 3, 3, 3, 0 ]As you can see, the combination of the fat arrow and a class instance causes wtf.bar.length to return zero. Is there a workaround for this? Is this "working as intended"? All sorts of various code uses the handy Function.length checks, and the inability to trust Function.length if the user declared the function as a fat-arrow function could cause problems (and already has for me).. Thoughts?