CodingTrain / CodingTrain/Suggestion-Box
How to pass parameters from objects in new ES6 Javascript
- Vorherrschende Sprache
- Keine Sprachdaten
- Sterne
- 570
- Forks
- 85
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
**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
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Rechercherichtung
Das Issue erwähnt nur die JavaScript-Snippets und keine Repository-Dateien oder Tests. Beginne mit der Prüfung der angeforderten Erklärung zur Objekterstellung in ES6 und p5.js; abgeschlossen wäre die Arbeit, wenn es ein klar abgegrenztes Dokumentationsthema oder Beispiel gibt, das beantwortet, wie die Datenobjekte an Bubble übergeben werden sollen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript
- Bereich
- documentation
- Issue-Typ
- Dokumentation
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 25/100