1 00:00:00,370 --> 00:00:05,000 We've seen that you cannot reassign a constant variable in the case of a number 2 00:00:05,000 --> 00:00:05,960 or a string. 3 00:00:05,960 --> 00:00:09,570 The same goes for any value of a constant variable. 4 00:00:09,570 --> 00:00:14,020 You cannot reassign strings, numbers, booleans, objects, and arrays. 5 00:00:14,020 --> 00:00:18,980 Unlike strings, numbers, and booleans, objects in arrays have methods and 6 00:00:18,980 --> 00:00:22,330 properties that modify the objects or array. 7 00:00:22,330 --> 00:00:24,430 Do they still work with const? 8 00:00:24,430 --> 00:00:31,520 First we'll declare a variable, which is a constant called days. 9 00:00:33,490 --> 00:00:39,282 This will contain an array with a single string "Monday". 10 00:00:39,282 --> 00:00:44,394 Second we'll declare another constant variable 11 00:00:44,394 --> 00:00:51,095 person that contains an object literal with a {first_name}. 12 00:00:52,736 --> 00:00:56,610 Key, with the string "Imogen". 13 00:00:59,670 --> 00:01:03,903 Let's attempt to modify these in the console here, first days. 14 00:01:06,799 --> 00:01:10,410 Let's use the push method to add another day to the array. 15 00:01:14,795 --> 00:01:21,410 It didn't error, it returned the number 2, meaning the new array length. 16 00:01:21,410 --> 00:01:28,800 If we type days, and hit Enter, we get Monday and Tuesday returned. 17 00:01:28,800 --> 00:01:32,245 Let's try and add a last_name property to the person object. 18 00:01:36,128 --> 00:01:38,060 Again no error. 19 00:01:38,060 --> 00:01:42,360 When we type person and hit Enter we get an object 20 00:01:42,360 --> 00:01:47,290 literal back with the first_name and last_name properties. 21 00:01:47,290 --> 00:01:49,090 So what's happening here? 22 00:01:49,090 --> 00:01:55,720 Const doesn't prevent complex objects like arrays and objects from being modified. 23 00:01:55,720 --> 00:02:00,820 It just prevents them from being reassigned or over written completely. 24 00:02:00,820 --> 00:02:06,351 For example, when I attempt to override 25 00:02:06,351 --> 00:02:11,567 person with another object literal. 26 00:02:16,503 --> 00:02:22,086 It shows an error, because I'm attempting to re-assign person with a new object. 27 00:02:25,125 --> 00:02:28,419 However, if I modified the first name. 28 00:02:32,747 --> 00:02:39,520 To equal another value, Andrew, I don't get any errors.