JavaScriptの文字列メソッドと小道具



Javaスクリプトストリングメソッド
長さのプロパティ
"abc".length
> 3
indexout ()メソッド
"abc".indexOf("b")
> 1
indexout ()メソッド
"abc".indexOf("i")
> -1
indexout ()メソッド
"abc".indexOf("")
> 0
lastindexo ()メソッド
"abcb".lastIndexOf("b")
> 3
indexout ()メソッド
"abcb".lastIndexOf("i")
> -1
indexout ()メソッド
"abcb".lastIndexOf("")
> 4
search ()メソッド
"abc".search("b")
> 1
indexout ()メソッド
"abc".search("i")
> -1
indexout ()メソッド
"abc".search("")
> 0
slice ()メソッド
"abc".slice("1")
> "bc"
slice ()メソッド
"abc".slice("5")
> ""
slice ()メソッド
"abc".slice("")
> "abc"
substr ()メソッド
"abc".substring("1")
> "bc"
substr ()メソッド
"abc".substring("5")
> ""
substr ()メソッド
"abc".substring("")
> "abc"
replace ()メソッド
"abc".replace("a","e")
>> "ebc"
touppercase ()メソッド
"abc".toUpperCase()
>> "ABC"
tolowercase ()メソッド
"ABC".toLowerCase()
>> "abc"
concat ()メソッド
"ABC".concat(",", "b")
>> "ABC,b"
trim ()メソッド
"  ABC abc  ".trim()
>> "ABC abc"
char ()メソッド
"  ABC abc  ".charAt(4)
>> "C"
charcodeat ()メソッド
"  ABC abc  ".charCodeAt(4)
>> 67
split ()メソッド
"a,b,c".split(",")
>> ["a", "b", "c"]
split ()メソッド
"a b c".split(" ")
>> ["a", "b", "c"]
split ()メソッド
"a b c".split("")
>> ["a", " ", "b", " ", "c"]