“Apa Indeks dari JavaScript” Kode Jawaban

Indeks JavaScript

//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
Grepper

indeks javascript dengan kondisi

a = [
  {prop1:"abc",prop2:"qwe"},
  {prop1:"bnmb",prop2:"yutu"},
  {prop1:"zxvz",prop2:"qwrq"}
];
    
index = a.findIndex(x => x.prop2 ==="yutu");

console.log(index);
Clever Crane

.index dari JavaScript

let monTableau = ['un', 'deux','trois', 'quatre'] ;
console.log(monTableau.indexOf('trois')) ;
 
Crevure 01

Indeks JS

const fruits = ["apple", "banana", "cantaloupe", "blueberries", "grapefruit"];

const index = fruits.findIndex(fruit => fruit === "blueberries");

console.log(index); // 3
console.log(fruits[index]); // blueberries
Breakable Bug

JS, indexof ();

function quickCheck(arr, elem) {
  return arr.indexOf(elem) != -1;
}
console.log(quickCheck(["squash", "onions", "shallots"], "mushrooms"));
Condemned Cheetah

Jawaban yang mirip dengan “Apa Indeks dari JavaScript”

Pertanyaan yang mirip dengan “Apa Indeks dari JavaScript”

Lebih banyak jawaban terkait untuk “Apa Indeks dari JavaScript” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya