This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Themabewertung:
  • 0 Bewertung(en) - 0 im Durchschnitt
  • 1
  • 2
  • 3
  • 4
  • 5
javascript Pfeil Funktionen
#1
function Person(firstName, lastName) {
    this.firstName = firstName;
    this.lastName = lastName;
    this.getFullName = () => `${this.first_name} ${this.last_name}`;
}

const person1 = new Person('John', 'Doe');

console.log(person1.getFullName);
Hallo, ich fange gerade an javascrpt zu lernen und habe mich gefragt warum dieser Coder hier nicht funktioniert währe nett wenn mir da jemand helfen könnte
Zitieren
#2
Hi Tim,
das was du geschrieben hast ist nicht möglich oder es hat kein Sinn. Die Pfeil-Funktion in JavaScript sind nur für Funktionen beziehungweise Funktionsausdrücke.

Deswegen geht dein Plan nicht auf. Um die Thematik besser verstehen zu können, habe ich drei lesenswerte Artikel/Seiten für dich heraus gesucht:

https://www.mediaevent.de/javascript/arr...ction.html

https://developer.mozilla.org/de/docs/We..._functions

https://wiki.selfhtml.org/wiki/JavaScrip...unktion.29

Ich hoffe die Links helfen dir weiter, um zu verstehen wo man anonyme Funktionen verwendet und warum nur bei Diesen die Arrow-function geht.

Wenn du weitere Fragen hast zu Funktionen, Objekte oder anderen Dingen in JS, dann einfach hier ins Forum schreiben.

Viele Grüße

rzscout
Als Lösung markieren Zitieren


Gehe zu:


Benutzer, die gerade dieses Thema anschauen: 2 Gast/Gäste