JavaScript 2022

Term 3 Wednesday

May - July 2022

This site will be updated live during the sessions

Week 8 2 Object Pointer

		
001const car = {
		
002	doors: 4,
		
003	colour: 'red',
		
004	maxspeed: 120
		
005}
		
006for(const property in car)
		
007{
		
008	console.log('propety name: ' + property);
		
009	console.log('Value : ' + car[property]);
		
010} 
		
011console.log(car.colour); // red
		
012
		
013const car2 = car;
		
014
		
015car2.colour = 'blue';
		
016
		
017console.log(car2.colour); // blue
		
018
		
019console.log(car.colour);  // blue
		
020
		
021/*
		
022
		
023if(car.hasOwnProperty('lights'))
		
024{
		
025	console.log(car.lights);
		
026}
		
027else{
		
028	console.log('the car doesn\'t have lights');
		
029}
		
030*/