Menu

Thursday, September 30, 2021

JavaScript String indexOf()

 

Example

Search a string for "welcome":

let str = "Hello world, welcome to the universe.";
str.indexOf("welcome")   // Returns 13
str.indexOf("Welcome")   // Returns -1

Definition and Usage

The indexOf() method returns the position of the first occurrence of a specified value in a string.

indexOf() returns -1 if the value is not found.

indexOf() is case sensitive.


Visitors that saw a url containing a specific value

 

Create an audience that visited the pages url containing “baby”.

 

if(page.url.indexOf('baby') != -1)

{

 return true;

}

 


No comments:

Post a Comment

Target Server Side implementation using .net SDK

 Target Server Side implementation using .net SDK  This reference guide shows how Adobe Target customers can install, initialize, and use th...