javascript string index code example
Example 1: how to get the first character of a string in javascript
let str = 'John Wick'
let firstChar = str.charAt(0)
console.log(firstChar);
Example 2: javascript indexof
var colors=["red","green","blue"];
var pos=colors.indexOf("blue");
var str = "We got a poop cleanup on isle 4.";
var strPos = str.indexOf("poop");
Example 3: indexof javascript
var colors=["red","green","blue"];
var pos=colors.indexOf("blue");
var str = "We got a poop cleanup on isle 4.";
var strPos = str.indexOf("poop");
<Checkbox
checked={value.indexOf(option) > -1}
value={option}
/>
Example 4: indefOf
const beasts = ['ant', 'bison', 'camel', 'duck', 'bison'];
console.log(beasts.indexOf('bison'));
Example 5: js indexof string
str.indexOf(searchValue[, fromIndex])
Example 6: indexof javascript
Array.indexOf(searchElement, fromIndex)