1 00:00:00,530 --> 00:00:04,600 You can also use dot notation to set the value of an object's property. 2 00:00:04,600 --> 00:00:09,150 You use the equal sign, or the assignment operator, just as you do with variables. 3 00:00:09,150 --> 00:00:13,040 For example, to change the name property of this student object, 4 00:00:13,040 --> 00:00:15,480 you assign it a new value like this. 5 00:00:15,480 --> 00:00:19,910 In fact, you can even create and add new properties to an object this way. 6 00:00:19,910 --> 00:00:24,760 For example, to add a city property to the student object, you'd write this. 7 00:00:24,760 --> 00:00:28,090 This not only adds a property named city to the object, but 8 00:00:28,090 --> 00:00:29,251 also assigns it a value. 9 00:00:30,500 --> 00:00:32,400 Back in the object.js file, 10 00:00:32,400 --> 00:00:36,510 let's change the value of the person object's name property. 11 00:00:37,930 --> 00:00:43,420 In the message, I'll include most 12 00:00:43,420 --> 00:00:50,010 know me ${ person.name = 'Duke'}. 13 00:00:51,010 --> 00:00:52,620 Let's see the updated message. 14 00:00:52,620 --> 00:00:56,040 I'll save the file and refresh the browser. 15 00:00:56,040 --> 00:00:59,120 Notice the original name property value, Edward, and 16 00:00:59,120 --> 00:01:01,200 the new value after changing it, Duke. 17 00:01:02,800 --> 00:01:04,930 If I type person into the console, 18 00:01:04,930 --> 00:01:09,550 it returns the updated person object with the name property set to Duke. 19 00:01:10,730 --> 00:01:13,020 You learn that you can create and 20 00:01:13,020 --> 00:01:16,450 add new properties to an object using dot notation. 21 00:01:16,450 --> 00:01:19,476 I'll add a new nickname property to the person object. 22 00:01:19,476 --> 00:01:25,850 We have person.nickname, and assign it the string, Duke. 23 00:01:28,520 --> 00:01:34,352 Then in the message, I'll change person.name here to person.nickname. 24 00:01:38,667 --> 00:01:40,920 Typing person into the console now, 25 00:01:40,920 --> 00:01:45,585 returns the person object with a new nickname property and value inside it. 26 00:01:49,442 --> 00:01:54,250 You can also perform math using properties set to numeric values. 27 00:01:54,250 --> 00:01:59,051 For example, in the message, 28 00:01:59,051 --> 00:02:05,706 I'll include my age is person.age + 1. 29 00:02:05,706 --> 00:02:09,933 The age property is set to 37 inside the object. 30 00:02:09,933 --> 00:02:15,656 By adding 1, the value displaying in the message is now 38. 31 00:02:19,291 --> 00:02:23,110 You can also access the properties of certain values. 32 00:02:23,110 --> 00:02:27,640 For example, the skills property is set to an array, you can 33 00:02:27,640 --> 00:02:32,130 use the length property on that array to return how many skills the person has. 34 00:02:32,130 --> 00:02:38,640 I'll add another sentence in the message that says, I have ${ } skills. 35 00:02:38,640 --> 00:02:43,207 Again, person is the object and skills is the property name. 36 00:02:43,207 --> 00:02:49,090 Between the curly braces type person.skills. 37 00:02:49,090 --> 00:02:53,634 Since the value assigned to skills is an array of string values, 38 00:02:53,634 --> 00:02:59,291 you can access the length property of the array with person.skills.length. 39 00:02:59,291 --> 00:03:02,430 You access methods of properties in a similar way. 40 00:03:02,430 --> 00:03:06,956 For example, to return a list of the person's skills, 41 00:03:06,956 --> 00:03:10,149 use the array join method, like this. 42 00:03:14,977 --> 00:03:18,380 You learned about the join method in a previous course. 43 00:03:18,380 --> 00:03:20,440 Here I start with the object, 44 00:03:20,440 --> 00:03:24,770 person, then access the skills property which is an array. 45 00:03:24,770 --> 00:03:27,740 Then use the join array method on that property, 46 00:03:27,740 --> 00:03:31,720 passing it a string containing a comma and space. 47 00:03:31,720 --> 00:03:35,900 That way a comma and space appear after each element in the array. 48 00:03:35,900 --> 00:03:40,530 The message now shows that Edward, or Duke, has 3 skills and 49 00:03:40,530 --> 00:03:44,140 they are JavaScript, HTML, and CSS, good. 50 00:03:44,140 --> 00:03:47,270 As you can see, working with object properties isn't 51 00:03:47,270 --> 00:03:49,740 all that different from working with variables. 52 00:03:49,740 --> 00:03:54,023 And objects are well arranged packages of information holding data you want to use 53 00:03:54,023 --> 00:03:54,774 in your code. 54 00:03:54,774 --> 00:03:55,677 In the next stage, 55 00:03:55,677 --> 00:03:58,960 you'll learn how to loop through all of the properties in an object.