Attendez que quelque chose se passe javascript

//1st methode : not good enough : very slow

const poller=setInterval(()=>{
  //if you want use async function 
   // return new Promise((resolve, reject) => {

  let bear=document.querySelector('ul.bears li')
  if(bear){
    console.log(bear)
    clearInterval(poller)
   // resolve(bear)
  }
   // })
},2000)


//2sd methode : (we will use mutation observer)
const observer= new MutationObserver((mutations)=>{
  mutations.forEach((mutation)=>{
    if(mutation.addedNodes.lenght){
      console.log(mutation.addedNodes[0])
       }
    
  })
})
// the elelemtn you wanna to observe
const bears=document.querySelector('ul.bears')
observer.observe(bears,{childList:true})
Marwen Labidi