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

119
Views
¿Cómo configurar una función como mapa o mapa débil con el siguiente código?

Quiere saber cómo configurar una función con un objeto como un mapa o un mapa débil. Y cómo identificar si usar mapa o mapa débil.

 function testCases() { let model = new JsModel({name: 'Harry', age: 20}); // few methods console.log(model.get('name')) // 'Harry' console.log(model.get('age')) // 20 // few other methods model.set('name', 'Bob'); console.log(model.get('name')) // 'Bob' console.log(model.has('name')) // true model.unset('name'); console.log(model.has('name')) // false const city = new JsModel(); // valid city.set('name', 'San Jose'); city.set('population', 1000); console.log( city.get('name')) // San Jose console.log( city.get('population')) // 1000 console.log(city.get('noProp')) // undefined } testCases();

Soy nuevo en Javascript, así que quiero entender si el código anterior me gusta cómo hacer que estos console.logs funcionen.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Escribí mucho javascript y nunca usé WeakMap. Así es como yo escribiría ese código.

 function testCases() { const model = {name: 'Harry', age: 20}; // few methods console.log(model.name) // 'Harry' console.log(model.age) // 20 // few other methods model.name = 'Bob'; console.log(model.name) // 'Bob' console.log(model.name !== undefined) // true delete model.name; console.log(model.name !== undefined) // false const city = {}; // valid city.name = 'San Jose'; city.population = 1000; console.log(city.name) // San Jose console.log(city.population) // 1000 console.log(city.noProp) // undefined } testCases();

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!