skip to Main Content

i have an object im looping through with a map

datas.children.map((datasAgain) => {
  if (datasAgain returns nothing) {
    // do something
   }
   return // do another thing
 })

datas.children is inside another map fuction and returns multiple lists of objects, one of those lists is empty "[]",
datasAgain returns objects inside of datas.children, how can i check if datasAgain returns nothing here? essentially checking if the list in datas.children is empty

2

Answers


  1. Before you do the loop, compare using the code below:

    if(datasAgain.length == 0){

    // your map
    

    }

    Login or Signup to reply.
  2. datas.children.map((datasAgain) => {
      if (datasAgain.length === 0) {
        // The list in datas.children is empty
        // Do something
      } else {
        // The list in datas.children is not empty
        // Do another thing
      }
      return // return value (if needed)
    });
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search