Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

327
Views
declaración de variable fuera del bloque if, utilizada dentro del bloque if no está definido fuera del bloque if

Esta pregunta se ha hecho antes, pero todavía no entiendo Establecer el valor de la variable en el bloque if. Valor de acceso fuera del bloque if En mi caso, eliminé una variable fuera del bloque if var title, artist, album, year pero cuando accedí fuera del bloque if filedata.push({fileName: file.name, location: path, title: title, artist: artist, album: album, year: year}) dice indefinido

 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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!