Object And Arrays


#1

Hello,
How can I declare a property of an object as an array I've already created?

i.e.

var array = ["things","stuff"];

var object = {
life: array[0],
death: array[1]
};

Thanks!


#2

@colinlmcdonald,
An object has one or more properties, separated by a comma_,

A property has a property-key and it's associated VALUE

The VALUE can be anything from:

•Number
•String
•Boolean
•Symbol
•Object  ◦Function
         ◦Array
	 ◦Date
         ◦RegExp
         ◦Math
•Null
•Undefined


var array = ["things","stuff"];

var object = {
   life: array[0],
   death: array[1],
   ld:[]
};
object.myArray=[];
console.log( object);

[ output ]

 { life: 'things', death: 'stuff', ld: [], myArray: [] }