JavaScript Several functions - Split (), JOIN (), SUBSTRING () and INDEXOF ()

zhaozj2021-02-16  137

Split () uses a specified separator to store a string to array tres = "thisqisqaqstring"; myListofwords = thesetring.split ("Q"); // myListofwords is a character value "this", "IS", "A" and "string" arrand

John () uses the separator you choose to combine a number combination and a string var delimitedString = MyArray.join (Delimiter); var mylist = new array ("Milk", "Eegs", "BUNS", "Hot Robots") Var portables ("|"); // The result is Milk | Eggs | BUNS | Hot Robots

Substring () If you want to get "Weis" from "Budweiser", Substring (3, 7)

INDEXOF () He returns the first character of the string of the first character of the hunt string var myString = "javascript"; var w = mystring.indexof ("v"); wll be 2var x = mYString.indexof ("s" "); x Will be 4var y = mystring.indexof (" script "); y Will Also be 4var z = mystring.indexof (" donkey "); z WILL BE -1

转载请注明原文地址:https://www.9cbs.com/read-7890.html

New Post(0)