0

Find if a string contains a substring in JavaScript!

This post will explain how to find a substring in a string using pure JavaScript. Let’s see how can we achieve this.

The above script will show an alert ‘true’ because sub-string ‘tin’ is present in the string ‘testing’. So basically to check a sub-string in JavaScript is to use indexOf()

Now, let’s see a full example of how to check this sub-string dynamically.

See the demo here:

demo

agurchand

Technologist, software engineer, blogger with experience in Web development and the Media.

Leave a Reply