1
0

More than 1 year has passed since last update.

Next.jsの備忘録

Last updated at Posted at 2022-05-10

前書き

Object.values(hoge)


const numbers=[1,2,3]

console.log(Object.values(numbers))


///実行結果
[1,2,3]


Array.prototype.some()

オブジェクトの中身をいじるのに使うもの。everyと違って、何個かに適用されるのみ。

//書き方

const numbers=[1,2,3]

 const textCheck = () => {
    if (Object.values(numbers).some((number) => (return(number*2))))
  }

Array.prototype.every()

オブジェクトの中身をいじるのに使うもの。someと違って、全てに適用される。

//書き方

const numbers=[1,2,3]

 const textCheck = () => {
    if (Object.values(numbers).every((number) => (return(number*2))))
  }

if文、三項演算子、switch文

const hogehoge =(numbers)=>{

const numbers=[1,2,3]

return(
<div>

//三項演算子
 <p>
  {numbers.[1] === 1 ? first:'others'}
 </p>
 <p>
  {numbers.[0] === 1 ? first : numbers.[1] === 2 ? second : numbers.[2] === 3 : third}
 </p>

//if文とswitch文
 <p>
  {(()=>{
    if(numbers === 1){
     return('first')
    }else{
   return('others')}
  }}
  {(()=>{
    switch(numbers){
     case '1':
       return('first')
     case '2':
       return('second')
     case '3':
       return('third')
      }
   })()}
 </p>
</div>

)}

追記中...

1
0
0

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
0