JavaScript

every(), some() - 자바스크립트

CD2Y 2022. 4. 11.
반응형

See the Pen every(): 모든 요소 검사 by nilgi (@nilgi) on CodePen.

 

<h3>every(): 모든 요소 검사</h3>
<p id="gr_e"></p>
<script type="text/javascript">
  const gr_nums = [123, 45, 6, 2, 575, 7, 45];
  let every_num = gr_nums.every(myFunction);

  document.getElementById("gr_e").innerHTML = every_num;

  function myFunction(value) {
    return value > 100;
  }
</script>



<h3>some(): 일부 요소 검사</h3>
<p id="gr_s"></p>
<script type="text/javascript">
  const gr_nums1 = [123, 45, 6, 2, 575, 7, 45];
  let some_num = gr_nums1.some(myFunction);

  document.getElementById("gr_s").innerHTML = some_num;

  function myFunction(value) {
    return value > 50;
  }
</script>

반응형