babel-plugin-array-includes icon indicating copy to clipboard operation
babel-plugin-array-includes copied to clipboard

Does not translate Array.prototype.include calls when using x['includes'](y)

Open jhford opened this issue 8 years ago • 1 comments

Kind of an edge case, but if you reference the includes property using [] instead of ., the plugin will not transform the code. Exampe:

x.includes(123);
x['includes'](123);

which should be identical in behaviour result in:

'use strict';

x.indexOf(123) !== -1;
x['includes'](123);
//# sourceMappingURL=test.js.map

Which I don't beleive is correct. Using babel-node confirms this:

> var x = [1,2,3]
undefined
> x.includes(1)
true
> x['includes'](1)
true

jhford avatar Apr 28 '16 09:04 jhford

Would you like to try and fix this as well? cheers

stoeffel avatar Apr 28 '16 11:04 stoeffel