Java script String Methods
length property
"abc".length
> 3
indexOf() method
"abc".indexOf("b")
> 1
indexOf() method
"abc".indexOf("i")
> -1
indexOf() method
"abc".indexOf("")
> 0
lastindexOf() method
"abcb".lastIndexOf("b")
> 3
indexOf() method
"abcb".lastIndexOf("i")
> -1
indexOf() method
"abcb".lastIndexOf("")
> 4
search() method
"abc".search("b")
> 1
indexOf() method
"abc".search("i")
> -1
indexOf() method
"abc".search("")
> 0
slice() method
"abc".slice("1")
> "bc"
slice() method
"abc".slice("5")
> ""
slice() method
"abc".slice("")
> "abc"
substring() method
"abc".substring("1")
> "bc"
substring() method
"abc".substring("5")
> ""
substring() method
"abc".substring("")
> "abc"
replace() method
"abc".replace("a","e")
>> "ebc"
toUpperCase() method
"abc".toUpperCase()
>> "ABC"
toLowerCase() method
"ABC".toLowerCase()
>> "abc"
concat() method
"ABC".concat(",", "b")
>> "ABC,b"
trim() method
" ABC abc ".trim()
>> "ABC abc"
charAt() method
" ABC abc ".charAt(4)
>> "C"
charCodeAt() method
" ABC abc ".charCodeAt(4)
>> 67
split() method
"a,b,c".split(",")
>> ["a", "b", "c"]
split() method
"a b c".split(" ")
>> ["a", "b", "c"]
split() method
"a b c".split("")
>> ["a", " ", "b", " ", "c"]
Top comments (0)