“JavaScript array beberapa” 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

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

JavaScript array beberapa

function isBiggerThan10(element, index, array) {
  return element > 10;
}

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

array.some ()

<script>
  
// JavaScript code for some() function 
function isodd(element, index, array) {  
    return (element % 2 == 1);  
} 
    
function geeks() { 
    var arr = [ 6, 1, 8, 32, 35 ]; 
      
    // check for odd number 
    var value = arr.some(isodd); 
    console.log(value); 
} 
geeks(); 
</script>
Helpless Hummingbird

Jawaban yang mirip dengan “JavaScript array beberapa”

Pertanyaan yang mirip dengan “JavaScript array beberapa”

Lebih banyak jawaban terkait untuk “JavaScript array beberapa” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya