“beberapa js” Kode Jawaban

JS menemukan array kembali benar -benar salah

['one', 'two'].some(item => item === 'one') // true
['one', 'two'].some(item => item === 'three') // false
foloinfo

js objek beberapa

let obj = {"num1":1, "num2":2, "num3":3, "num4":4, "num5":5};

var firstEven = null;

// Some returns a boolean value.
Object.values(obj).some((item) => {
	// Loop breaks as soon as the condition has been met.
  	// Getting your value, can be used like:
  	if	(item == 2) {
		firstEven = item;
	}
	return item % 2 == 0;
}); // Results in true
Av3

Beberapa JS ES6

const array = [1, 2, 3, 4, 5];

// checks whether an element is even
const even = (element) => element % 2 === 0;

console.log(array.some(even));
// expected output: true
MM.Mirzaei.Dev

javascript beberapa

const fruits = ['apple', 'banana', 'mango', 'guava'];

function checkAvailability(arr, val) {
  return arr.some(function(arrVal) {
    return val === arrVal;
  });
}

checkAvailability(fruits, 'kela');   // false
checkAvailability(fruits, 'banana'); // true
Dangerous Dogfish

beberapa js

[2, 5, 8, 1, 4].some(isBiggerThan10);  // false
[12, 5, 8, 1, 4].some(isBiggerThan10); // true
Filthy Flatworm

Jawaban yang mirip dengan “beberapa js”

Pertanyaan yang mirip dengan “beberapa js”

Lebih banyak jawaban terkait untuk “beberapa js” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya