DEV Community

Cover image for JAVASCRIPT STRING METHODS and PROPS
 Bishnu Prasad Chowdhury
Bishnu Prasad Chowdhury

Posted on • Edited on

JAVASCRIPT STRING METHODS and PROPS

Java script String Methods

length property

"abc".length
> 3
Enter fullscreen mode Exit fullscreen mode

indexOf() method

"abc".indexOf("b")
> 1
Enter fullscreen mode Exit fullscreen mode

indexOf() method

"abc".indexOf("i")
> -1
Enter fullscreen mode Exit fullscreen mode

indexOf() method

"abc".indexOf("")
> 0
Enter fullscreen mode Exit fullscreen mode

lastindexOf() method

"abcb".lastIndexOf("b")
> 3
Enter fullscreen mode Exit fullscreen mode

indexOf() method

"abcb".lastIndexOf("i")
> -1
Enter fullscreen mode Exit fullscreen mode

indexOf() method

"abcb".lastIndexOf("")
> 4
Enter fullscreen mode Exit fullscreen mode

search() method

"abc".search("b")
> 1
Enter fullscreen mode Exit fullscreen mode

indexOf() method

"abc".search("i")
> -1
Enter fullscreen mode Exit fullscreen mode

indexOf() method

"abc".search("")
> 0
Enter fullscreen mode Exit fullscreen mode

slice() method

"abc".slice("1")
> "bc"
Enter fullscreen mode Exit fullscreen mode

slice() method

"abc".slice("5")
> ""
Enter fullscreen mode Exit fullscreen mode

slice() method

"abc".slice("")
> "abc"
Enter fullscreen mode Exit fullscreen mode

substring() method

"abc".substring("1")
> "bc"
Enter fullscreen mode Exit fullscreen mode

substring() method

"abc".substring("5")
> ""
Enter fullscreen mode Exit fullscreen mode

substring() method

"abc".substring("")
> "abc"
Enter fullscreen mode Exit fullscreen mode

replace() method

"abc".replace("a","e")
>> "ebc"
Enter fullscreen mode Exit fullscreen mode

toUpperCase() method

"abc".toUpperCase()
>> "ABC"
Enter fullscreen mode Exit fullscreen mode

toLowerCase() method

"ABC".toLowerCase()
>> "abc"
Enter fullscreen mode Exit fullscreen mode

concat() method

"ABC".concat(",", "b")
>> "ABC,b"
Enter fullscreen mode Exit fullscreen mode

trim() method

"  ABC abc  ".trim()
>> "ABC abc"
Enter fullscreen mode Exit fullscreen mode

charAt() method

"  ABC abc  ".charAt(4)
>> "C"
Enter fullscreen mode Exit fullscreen mode

charCodeAt() method

"  ABC abc  ".charCodeAt(4)
>> 67
Enter fullscreen mode Exit fullscreen mode

split() method

"a,b,c".split(",")
>> ["a", "b", "c"]
Enter fullscreen mode Exit fullscreen mode

split() method

"a b c".split(" ")
>> ["a", "b", "c"]
Enter fullscreen mode Exit fullscreen mode

split() method

"a b c".split("")
>> ["a", " ", "b", " ", "c"]
Enter fullscreen mode Exit fullscreen mode

Top comments (0)