#100DaysOfWeb in Python Transcripts
Chapter: Days 25-28: JavaScript Introduction
Lecture: Objects

Login or purchase this course to watch this video and the rest of the course contents.
0:01 In this video, we will look at objects.
0:04 They are fundamental building block in JavaScript.
0:09 Like Python, everything in JavaScript is an object.
0:15 You can say person is Bob.
0:21 You can method on that object.
0:27 As a data type and at the most basic level
0:30 objects can be seen as dictionaries in Python
0:33 and they can in find one using an object literal.
0:37 If you're familiar with the platform
0:39 you know that our exercises are called bytes.
0:42 Let's define a byte.
0:54 A nice thing is that in JavaScript
0:56 you can access the properties
0:58 with a dot notation
1:02 but also like a dictionary in Python.
1:07 Now objects in JavaScript
1:09 are way more than just dictionaries.
1:11 They're fully fledged classes under the hood
1:15 so we can also add methods.
1:16 For example, if we will do something
1:18 like the Dunder STR in Python
1:21 you can do that straight on the object.
1:28 And I forgot to mention in the last lesson
1:29 that anonymous functions are defined like this.
1:32 Now I'm just starting to print the info of the object
1:35 to the console
1:39 and to actually access the properties
1:41 I need to use this, a bit like self in Python.
1:50 So then I can call that method
1:55 and I get a nice output.
1:57 So the recap, like Python and JavaScript
2:00 almost everything is an object.
2:03 You can define a variable
2:05 and we can call methods on that object.
2:12 All JavaScript objects inherit properties and methods
2:14 from a prototype.
2:16 Now a prototypes are beyond of this beginner lesson
2:19 but I encourage you to look into it further
2:21 because it supports powerful object-oriented
2:23 program features.
2:28 To create a simple object
2:29 we can use an object literal
2:31 which seems like a dictionary in Python.
2:36 We can access the attributes or properties
2:38 by the dolt notation or putting the keys in square brackets.
2:46 We can add methods to our objects
2:48 using the anonymous function notation
2:52 and here it just bounced the object information
2:54 to the console
2:55 and to reference object attributes
2:57 I need to this keyword which is similar to the self keyword
3:01 in Python classes.
3:05 Here I call the method and again an output.
3:13 To inspect objects
3:16 you can use console lock
3:17 and when you click on the arrow
3:19 you get a nice representation of the object.
3:22 You can also use Jason string a pie
3:24 to serialize it to a string.
3:27 One important notice that objects are copied by reference
3:30 by default
3:31 so I would assign byte to a new variable
3:34 called by two and I changed one of their properties
3:36 that change is reflected in both objects.
3:38 Some something to keep in mind.
3:40 This concludes the basic JavaScript construct of day one
3:44 and tomorrow on day two
3:45 I got four exercises lined up
3:47 to make you practice the materials
3:49 that you've learned so far.
3:51 See you tomorrow.