Function: indexOf() Function: Return the subscript of the first character matching the substring in the string
var myString="JavaScript";
var w=myString.indexOf("v");w will be 2
var x=myString.indexOf("S");x will be 4
var y=myString.indexOf("Script");y will also be 4
var z=myString.indexOf("key" );z will be -1
Function: split()
Function: Use a specified delimiter to split a string and store it in an array
str="jpg|bmp|gif|ico|png";
arr=theString.split("|");
//arr is an array containing the character values "jpg", "bmp", "gif", "ico" and "png"
Function: Join()
Function: Combine an array into a string using the delimiter of your choice var delimitedString=myArray.join(delimiter);
var delimitedString=myArray.join(delimiter);
var myList=new Array( "jpg","bmp","gif","ico","png");
var portableList=myList.join("|");
//The result is jpg|bmp|gif|ico |png
Function: slice() and substring() Both slice and substring can accept one or two parameters, the first parameter is to get the content to be intercepted The direct starting position of the string. If the second parameter is not empty, it is the previous digit of the end position of the string to be intercepted (that is, the end position obtained is not within the return value). If it is empty, it means that the entire The last character of the string.
Note: The number of digits in the string starts from 0
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn