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

250
Views
Clase Javascript, con un parámetro pasado a la matriz;

Estoy tratando de invocar una clase con el siguiente código:

 class matchDetails { constructor(game, kit, player){ this.game = game; // This remains static; this.kit = color; // This remains static; this.player = new Array(player); } addMatchDetails(){ // return "Coventry"; } } ab = new matchDetails(23, 'red', 11);

En el constructor, quiero que this.player sea una matriz donde pueda insertar valores adicionales, pero no puedo entender cómo codificarlo.

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

0

El enfoque más simple es continuar extendiendo su constructor y agregar líneas. Puede inicializar la matriz y empujar el valor. Vea el ejemplo a continuación:

 class matchDetails { constructor(game, kit, player){ this.game = game; this.kit = kit; this.player = []; this.player.push(player) } addMatchDetails(){ // return "Coventry"; } } ab = new matchDetails(23, 'red', 'smith'); //pushing additional surnames ab.player.push('jones'); console.log(ab) //matchDetails { game: 23, kit: 'red', player: [ 'smith', 'jones' ] }

Además, no hay una variable de "color", así que la cambié a "kit".

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!