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 ".

1 Comment »

  1. Oi, Eu acho este site ótimo . Eu adorei .
    Irei voltar novamente e até já marquei nos favoritos. Sucesso!!

    Comment by — December 5, 2018 @ 4:41 am

RSS feed for comments on this post. TrackBack URL

Leave a comment Notes of web-specialist
Since 2009