Zum Hauptinhalt springen
tsecurity.de LIVE
Echtzeit-Radar & Feeds
Alle RSS Feeds
👥 Community & Social
IT Security DownloadsGitHub Release: openclaw/openclaw v2026.7.35 (20.09.2026)(20.09.2026 um 21:37 Uhr)
IT Security DownloadsGitHub Release: openclaw/openclaw v2026.7.35 (20.09.2026)(20.09.2026 um 21:37 Uhr)
Intelligence View
⚡ tsecurity.de Intelligence

The new Keyword in JavaScript

Reagiere als Erste:r — dein Feedback zählt!

If you've ever written new Person("Alice") and wondered what's actually happening behind the scenes — this post is for you.

what is constructor function?
A constructor function is just a regular function, but by convention we capitalize its name to signal it should be called with new.

function Person(name, age) {
  this.name = name;
  this.age  = age;
}

Inside it, this refers to the new object being built. That's the key idea.
What does new actually do?
When you write:

const alice = new Person("Alice", 30);

JavaScript silently does four things for you:

  1. Creates a brand-new empty object
// internally: const this = {};

2.Links it to the constructor's prototype

// internally: this.__proto__ = Person.prototype;

This is how alice can call methods like greet() even though they aren't stored on alice itself.
3.Runs the constructor body with this as that new object

this.name = "Alice";

4.Returns the object automatically.You don't need a return statement — new handles it

Putting methods on the prototype
Instead of copying a method into every instance (wasteful!), you add it once to the prototype:

Person.prototype.greet = function() {
  console.log("Hi, I'm " + this.name);
};

const alice = new Person("Alice", 30);
const bob   = new Person("Bob",   25);

alice.greet(); // "Hi, I'm Alice"
bob.greet();   // "Hi, I'm Bob"

Both alice and bob share the same greet function. Neither instance stores a copy — they just look up the chain.
The prototype chain

When you call alice.greet(), JavaScript searches in this order:

Does alice have greet directly? → No
Does alice.proto (= Person.prototype) have greet? → Yes! Use it.

This chain of lookups is called the prototype chain.

Summary:

  1. A constructor function is a blueprint for creating objects.
  2. new creates an empty object, links its prototype, runs the constructor, and returns the result.
  3. Own data lives on the instance; shared methods live on the prototype.
  4. When a property isn't found on the instance, JavaScript walks up the prototype chain to find it.
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten The new Keyword in JavaScript

Thematisch verwandte Begriffe: Keyword, JavaScript · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-93956 | A flaw has been found in olivier-ls PHP-FTS up to 1.1.2. Affected by thi…
Advisory →
TTS Reader • tsecurity.de Voice
tsecurity.de Icon
tsecurity.de App
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen

tsecurity.de Live Threat Radar

🔴 LIVE RADAR
MONITORING
AKTIV
CVE-DATENBANK
LIVE
🔍
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
🔖 Gespeicherte Artikel
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel Rechts: nächster Artikel unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...

Zurück: vorheriger Vor: nächster
↗ Original-Quelle
Social Reaktionen Deine Reaktion zählt
Einstufung & Relevanz-Poll 0 Stimmen
In sozialen Netzwerken teilen 1-Klick