1 00:00:00,350 --> 00:00:04,980 We've seen that you cannot reassign a constant variable in the case of a number 2 00:00:04,980 --> 00:00:05,940 or a string. 3 00:00:05,940 --> 00:00:08,998 The same goes for any value of a constant variable. 4 00:00:08,998 --> 00:00:14,000 You cannot reassign strings, numbers, booleans, objects, and arrays. 5 00:00:14,000 --> 00:00:18,960 Unlike strings, numbers and booleans, objects in arrays have methods and 6 00:00:18,960 --> 00:00:22,310 properties that modify the objects or array. 7 00:00:22,310 --> 00:00:24,370 Do they still work with const? 8 00:00:24,370 --> 00:00:31,490 First, we'll declare a variable which is a constant called days. 9 00:00:33,480 --> 00:00:36,930 This will contain an array with a single string, Monday. 10 00:00:39,330 --> 00:00:45,968 Second, we'll declare another constant variable, 11 00:00:45,968 --> 00:00:51,451 person, that contains an object's literal 12 00:00:51,451 --> 00:00:57,522 with a first_name key, with the string Imogen. 13 00:00:59,456 --> 00:01:02,950 Let's attempt to modify these in the console here. 14 00:01:02,950 --> 00:01:10,370 First, days, Let's use the push method to add another date to the array. 15 00:01:14,834 --> 00:01:16,500 It didn't error. 16 00:01:16,500 --> 00:01:21,390 It returned the number 2, meaning the new array length. 17 00:01:21,390 --> 00:01:28,780 If we type days and hit Enter, we get Monday and Tuesday returned. 18 00:01:28,780 --> 00:01:38,030 Let's try and add a last_name property to the person object, Again no error. 19 00:01:38,030 --> 00:01:42,930 When we type person and hit Enter, we get an object literal back 20 00:01:42,930 --> 00:01:47,270 with the first_name and last_name properties. 21 00:01:47,270 --> 00:01:49,070 So what's happening here? 22 00:01:49,070 --> 00:01:55,690 Const doesn't prevent complex objects like arrays and objects from being modified. 23 00:01:55,690 --> 00:02:00,678 It just prevents them from being reassigned or overwritten completely. 24 00:02:00,678 --> 00:02:06,947 For example, when I attempt to overwrite 25 00:02:06,947 --> 00:02:12,686 person with another object literal. 26 00:02:16,468 --> 00:02:21,990 It shows an error, because I'm attempting to reassign person with a new object. 27 00:02:25,108 --> 00:02:28,285 However, if I modified the first_name, 28 00:02:32,642 --> 00:02:38,958 To equal another value, Andrew, I don't get any errors.