1var colors = ["white","blue"];
2colors.unshift("red"); //add red to beginning of colors
3// colors = ["red","white","blue"]
1var person = {
2 "first_name": "Bob",
3 "last_name": "Dylan"
4};
5person.hasOwnProperty('first_name'); //returns true
6person.hasOwnProperty('age'); //returns false
1const names = ["Bob", "Cassandra"]
2
3names.unshift("Alex")
4
5names === ["Alex", "Bob", "Cassandra"]
1//Add element to front of array
2var numbers = ["2", "3", "4", "5"];
3numbers.unshift("1");
4//Result - numbers: ["1", "2", "3", "4", "5"]
1/*The unshift() adds method elements to the beginning, and push() method
2adds elements to the end of an array.*/
3let twentyThree = 'XXIII';
4let romanNumerals = ['XXI', 'XXII'];
5
6romanNumerals.unshift('XIX', 'XX');
7// now equals ['XIX', 'XX', 'XXI', 'XXII']
8
9romanNumerals.push(twentyThree);
10// now equals ['XIX', 'XX', 'XXI', 'XXII', 'XXIII']