We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Array.prototype.myIncludes = function (value, start = 0) { start = start < 0 ? this.length + start : start; for (let i = start; i < this.length; i++) { if (this[i] == value || (Number.isNaN(value) && Number.isNaN(this[i]))) return true; } return false; };
The text was updated successfully, but these errors were encountered:
Array.prototype.includes = function(searchElement, fromIndex) { // 如果数组为空,则直接返回 false if (this.length === 0) { return false; } // 如果未传递 fromIndex 参数,则默认为 0 fromIndex = fromIndex || 0; // 如果 fromIndex 是负数,则将其转换为从数组末尾算起的索引 if (fromIndex < 0) { fromIndex = this.length + fromIndex; } // 遍历数组,查找是否存在指定元素 for (var i = fromIndex; i < this.length; i++) { if (this[i] === searchElement) { return true; } } return false; }
Sorry, something went wrong.
No branches or pull requests
The text was updated successfully, but these errors were encountered: