Answers for "javascript index of string"

30

javascript get last character in string

var hello = "Hello World";
var lastCharOfHello=hello.slice(-1);//d
Posted by: Guest on August-01-2019
49

javascript indexof

//indexOf getting index of array element, returns -1 if not found
var colors=["red","green","blue"];
var pos=colors.indexOf("blue");//2

//indexOf getting index of sub string, returns -1 if not found
var str = "We got a poop cleanup on isle 4.";
var strPos = str.indexOf("poop");//9
Posted by: Guest on June-27-2019

Code answers related to "javascript index of string"

Code answers related to "Javascript"

Browse Popular Code Answers by Language