Javascript Array-constructor

De constructor-eigenschap JavaScript Array retourneert de constructorfunctie voor de array.

De syntaxis voor toegang tot de constructoreigenschap is:

 arr.constructor

Hier is arr een array.

Retourwaarde van constructor

  • Retourneert de constructorfunctie voor de array.

Voor JavaScript-arrays retourneert de constructoreigenschap de functie Array () ((native code)) .

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

Voorbeeld: constructor-eigenschap gebruiken

 let array = (1, 2, 3, 4, 5); let constructor = array.constructor; console.log(constructor) // Array() ( (native code) )

Uitvoer

 Array () ((eigen code))

Aanbevolen literatuur: JavaScript Constructor-functie

Interessante artikelen...