π κΆκΈν λͺ¨λ κ²μ κΈ°λ‘ν©λλ€.
π κΈ°λ‘μμ λ©μΆμ§ μκ³ λμ κ²μΌλ‘ λ§λλλ€.
π μλͺ»λ μ λ³΄κ° μλ€λ©΄ μΈμ λ μ§ λκΈμ λ¨κ²¨μ£ΌμΈμ :D
π€ some()?
some λ©μλλ λ°°μ΄ μμ μ΄λ€ μμλΌλ μ£Όμ΄μ§ ν¨μλ₯Ό ν΅κ³Όνλμ§ ν
μ€νΈνλ€.
μ½λ°±ν¨μλ μ£Όμ΄μ§ λ°°μ΄μ μμλ₯Ό κ²μ¬ν΄μ μ°ΈμΈ κ°μ μ°Ύλλ€.
κ·Έλ¦¬κ³ some λ©μλμμλ λ¨ νλμ μμλΌλ μ½λ°±ν¨μμμ μ°ΈμΈ κ°μ΄λΌλ©΄, μ¦μ trueλ₯Ό λ°ννκ³ μνκ° μ€λ¨λλ€. λͺ¨λ κ°μ΄ κ±°μ§μ΄λΌλ©΄ falseλ₯Ό λ°ννλ€.
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
π€ every()?
every λ©μλλ λ°°μ΄ μμ λͺ¨λ μμκ° μ£Όμ΄μ§ ν¨μλ₯Ό ν΅κ³Όνλμ§ ν
μ€νΈνλ€.
every λ©μλλ μ½λ°±μ΄ κ±°μ§μ λ°ννλ μμλ₯Ό μ°Ύμ λκΉμ§ λ°°μ΄μ κ° μμμ μ½λ°±ν¨μλ₯Ό μ€ννλ€. ν΄λΉ μμλ₯Ό λ°κ²¬νλ©΄ μ¦μ falseλ₯Ό λ°ννκ³ , μνκ° μ€λ¨λλ€. λͺ¨λ κ°μ΄ μ°Έμ΄λ©΄ trueλ₯Ό λ°ννλ€.
const isBelowThreshold = (currentValue) => currentValue < 40;
const array1 = [1, 30, 39, 29, 10, 13];
console.log(array1.every(isBelowThreshold));
// expected output: true
Top comments (0)