CodingTrain / CodingTrain/Suggestion-Box
How to pass parameters from objects in new ES6 Javascript
- Lingua principale
- Nessun dato sulla lingua
- Stelle
- 570
- Fork
- 85
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
**HI can someone plz help with this.
Recently watched The Doting Train Video abt ES6 classes with arguments and stuff. I had this doubt about, how to work around this syntax jargon.**
am using **p5.js**
```
b1 = new Bubble(data1);
b2 = new Bubble(data2);
```
I also have data1 for b1 and data2 for b2. How can I write this down?
```
class Bubble {
constructor(x, y, r) {
this.x = x,
this.y =y,
----
}
move() {
this.x = this.x + random(-5, 5);
this.y = this.y + random(-5, 5);
}
show() {
ellipse(this.x, this.y, this.r*2);
}
}
```
where data1 and data2 are similar in structure but have different values
```
function data1() {
this.x = 100,
this.y = 50,
this.r =10
}
```
Is there any **elegant** **method** of writing this? Thanks again! :D
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Direzione di ricerca
La issue menziona solo gli snippet JavaScript e nessun file o test del repository. Inizia esaminando la spiegazione richiesta sulla costruzione degli oggetti in ES6 e p5.js; il lavoro sarebbe completato quando fosse presente un argomento della documentazione o un esempio chiaramente delimitato che risponda a come debbano essere passati gli oggetti dati a Bubble.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- javascript
- Ambito
- documentation
- Tipo di issue
- Documentazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 25/100