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

152
Views
Preguntas de mapeo de objetos JS

He estado tratando de entender esta parte del código:

 if(stack.length > 0 && map[stack[stack.length - 1]] === s[i])

en la línea 9. ¿Qué significa "map[stack[stack.length-1]]"? Al principio pensé que el mapa es un objeto, pero creo que se supone que debes agregar la marca " " alrededor de las propiedades. ¿Es el mapa una estructura de datos? si es así, ¿cómo puedo usar esta estructura de datos?

 var stack = []; var len = s.length; var map = { '(': ')', '[': ']', '{': '}', }; for(var i = 0; i<len; i++){ if(stack.length > 0 && map[stack[stack.length - 1]] === s[i]) { stack.pop(); }else{ stack.push(s[i]); } } return stack.length === 0; };
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

El mapa es un objeto y

 map[stack[stack.length - 1]]

es la propiedad de 'map' cuya clave es el valor del último elemento de la pila del arreglo. Como se puede acceder a las propiedades de un objeto de ambas formas

 const object = { "property1" : value1, "property2" : value2, } object.property1 == object['property1']; // is true object.property2 == object['property2']; // is also true
about 4 years ago · Juan Pablo Isaza Report
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!