Multi-dimensional arrays and objects in javascript and how to’s

I have been working with Javascript since a long time and here are the things I use frequently. Before reading please note that this post will be updated continuously to add more about arrays and objects in javascript.

# Arrays

How to define an array?

var arr = ['Bus','Car','Truck'];

Get the value from array

arr.forEach(function(value){
console.log(value);
});
// returns
Bus
Car
Truck

Add new value to array

arr.push('Motorcycle');

Check if given array empty

console.log(arr.length === 0 ? true : false);
// returns
false

# Objects

How to define an object?

var obj = {
'type': 'Passenger',
'vehicle': 'Bus'
}

Get the value of a property in an object

console.log(obj.vehicle);
// returns
Bus

Add new property to same object

obj.seats = 20;

Add another new object

var newObj = {
'type': 'Passenger',
'vehicle': 'Car',
'seats': 5
}
obj.push(newObj);

Check if object is empty

console.log(Object.keys(obj).length === 0 ? true : false);
// returns
false

Thank you for reading and sorry for very less explanation. Please let me know if there’s any mistake or something is not working. As I’ve mentioned earlier, this article will be updated frequently.