JavaScript Scope Constructor invocation

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

When a function is invoked as a constructor with the new keyword this takes the value of the object being constructed

function Obj(name) {
    this.name = name;
}

var obj = new Obj("Foo");

console.log(obj);

This will log

{ name: "Foo" }



Got any JavaScript Question?