JavaScript Array constructor eigenschap

Definitie en gebruik

In JavaScript:constructor De eigenschap retourneert de constructor van het object.

Deze retourwaarde is een verwijzing naar de functie, niet de naam van de functie:

Voor JavaScript-arrays retourneert de constructor-eigenschap:
function Array() { [native code] }

Voor JavaScript-objecten retourneert de constructor-eigenschap:
function Object() { [native code] }

Instantie

De constructor-eigenschap retourneert de constructor van het array:

var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.constructor;
// Retourneert function Array() { [native code] }

Probeer het zelf

Syntax

array.constructor

Technische details

Retourwaarde: function Array() { [native code] }
JavaScript versie: ECMAScript 1

Browserondersteuning

Alle browsers ondersteunen dit volledig constructor Eigenschappen:

Chrome IE Edge Firefox Safari Opera
Chrome IE Edge Firefox Safari Opera
Support Support Support Support Support Support

Related pages

Tutorial:JavaScript array

Tutorial:JavaScript array Const

Tutorial:JavaScript array methods

Tutorial:JavaScript sort array

Tutorial:JavaScript array iteration