how to get element of an array in javascript
var value = [a,b,c,d];
var value_b = value[1];
how to get element of an array in javascript
var value = [a,b,c,d];
var value_b = value[1];
function search in javascript array
// function to search array using for loop
function findInArray(ar, val) {
for (var i = 0,len = ar.length; i < len; i++) {
if ( ar[i] === val ) { // strict equality test
return i;
}
}
return -1;
}
// example array
var ar = ['Rudi', 'Morie', 'Halo', 'Miki', 'Mittens', 'Pumpkin'];
// test the function
alert( findInArray(ar, 'Rudi') ); // 0 (found at first element)
alert( findInArray(ar, 'Coco') ); // -1 (not found)
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us