I use the following code in CoffeeScript:
if elem in my_array
do_something()
What compiles with this javascript:
if (__indexOf.call(my_array, elem) < 0) {
my_array.push(elem);
}
I see this using the __indexOf function, which is defined at the top of the script.
My question is about this use case: I want to remove an element from an array, and I want to support IE8. I can easily do this with indexOfand splicein browsers that support indexOfthe object array. However, in IE8 this does not work:
if (attr_index = my_array.indexOf(elem)) > -1
my_array.splice(attr_index, 1)
I tried using a function __indexOfdefined by CoffeScript, but I received a reserved word error in the compiler.
if (attr_index = __indexOf.call(my_array, elem) > -1
my_array.splice(attr_index, 1)
, CoffeScript indexOf? , , CoffeeScript ...