angular-payments
angular-payments copied to clipboard
what is this code?
found in validate.js
var __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }
i'm just curious. in validate.js many of the names are prefixed with an _
but not in other files.
line 55 of validate.js
return ref = cvc.length, __indexOf.call((ref1 = Cards.fromType(type)) != null ? ref1.cvcLength : void 0, ref) >= 0;
i have no idea what this is doing. how is __indexOf
useful in this code? __.indexOf
returns a value, however it doesn't look like it's being assigned to anything.
why is this code like this. how can someone understand this?
I am trying to get your code to pass the jshint linter. i am refactoring it so that i uses angular to make an HTTP call, either through $http or restangular. I am having a lot of trouble understanding validate.js.
Hey @boxxxie, __indexOf
seems to be a polyfill of indexOf
to provide backwards compatibility with older browsers