⊗jsOpAdMC 42 of 60 menu

Method source code in OOP in JavaScript

You can get the source code of a class method if you access it without parentheses. Let's try. Let's say we have the following class:

class User { #name; constructor(name) { this.#name = name; } getName() { return this.#name; } }

Let's create an object of this class:

let user = new User('john');

Let's output the source code of the method:

console.log(user.getName);

Print the source code of some method of class Employee.

English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline