1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

アロー関数で波括弧のなかに判定式がある場合はreturnが必要

Last updated at Posted at 2023-02-04
example.js
arr = []
arr.push(1,2,3,4,5)

// ネストしない場合はreturnは不要
const exist = arr.some(number => number == 1)
console,log(exist)//true

// false ネストしている場合はreturnが必要
const exist = arr.some(number => {
    number == 1
})
console.log(exit)//false

// ネストしている場合はreturnが必要
const exist = arr.some(number => {
    return number == 1
})
console.log(exist)//true
1
1
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?