Skip to content

Instantly share code, notes, and snippets.

@mojaray2k
Last active April 24, 2020 05:53
Show Gist options
  • Save mojaray2k/00881578fb523580e571a8395deba43d to your computer and use it in GitHub Desktop.
Save mojaray2k/00881578fb523580e571a8395deba43d to your computer and use it in GitHub Desktop.
Array constructor Property

Definition and Usage

In JavaScript, the constructor property returns the constructor function for an object.

The return value is a reference to the function, not the name of the function:

For JavaScript arrays the constructor property returns function Array() { [native code] }

For JavaScript numbers the constructor property returns function Number() { [native code] }

For JavaScript strings the constructor property returns function String() { [native code] }

// The constructor property returns an array's constructor function:
var fruits = ["Banana", "Orange", "Apple", "Mango"];
console.log(fruits.constructor);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment