String functions to find Contains and to Replace in Javascript




Below I described two string javascript functions that I often forget. 

"If string Contains" in Javascript you can determine using "indexOf()" command.

If substring is not found, the result is -1. That’s why it’s better to compare with "-1":

 

To replace substring you should use String.Replace command. The syntax to replace the word "World" to nothing ('') is like this:

The result is "Hello ".



MarkiMarta.com. Notes of web-specialist
Since 2009
18+
jQuery. How to get ID of clicked element

When I wanted to get the ID of clickable element using jQuery, I have found out that I don't remmember...

Close