It can also be called as a generic method.JavaScript includes() searches array or string with case sensitivity.It returns boolean true if any match is found or false otherwise. With a negative value, it applies this formula to compute the position to start.įromIndex = arrayLength + signedFromIndex The fromIndex is optional and its default value is 0 to start with. It has two parameters, searchElement and fromIndex. Syntax, parameters and return value includes(searchElement, ) In the string prototype, the includes() in JavaScript checks if the given value is the substring. In an array context, it checks the given value is one among the array elements. It checks if an array or string includes a given value. InputString.includes('learn','8') //returns false InputString.includes('learn') //returns true InputString = 'How to learn JavaScript?' InputArray.includes('Delete','-1') //returns false InputArray.includes('Error') //returns false InputArray.includes('Read','3') //returns false InputArray.includes('Read') //returns true
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |