Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

333
Visualizações
variable declaration outside if block, used inside if block is undefined outside if block

This question has been asked before but I still don't get the understanding Set value of variable in the if block. Access value outside if block In my case I decleared a variable outside the if block var title, artist, album, year but when I accessed it outside the if block filedata.push({fileName: file.name, location: path, title: title, artist: artist, album: album, year: year}) it says undefined

function selectMusic() {
  const fileList = songs.files
  for (let i=0; i < fileList.length; i++) {
    let file = fileList.item(i)
    var path = (window.URL || window.webkitURL).createObjectURL(file)
    var reader = new FileReader();
    var title, artist, album, year
    reader.onload = function(e) {
      var dv = new jDataView(this.result);
      // "TAG" starts at byte -128 from EOF.
      if (dv.getString(3, dv.byteLength - 128) == 'TAG') {
        title = dv.getString(30, dv.tell());
        artist = dv.getString(30, dv.tell());
        album = dv.getString(30, dv.tell());
        year = dv.getString(4, dv.tell());
      } else {
        console.log('id3 metadata not found')
      }
    };
    reader.readAsArrayBuffer(file);
    filedata.push({fileName: file.name, location: path, title: title, 
    artist: artist, album: album, year: year})
    //console.log(file.name)
    console.log(filedata)
  }
  //const arr = Array.from(fileList)
  // Load song initially
  loadSong(filedata[songIndex]);
}
about 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda