1 00:00:00,263 --> 00:00:01,251 So what is an object? 2 00:00:01,251 --> 00:00:02,575 An object is a neat and 3 00:00:02,575 --> 00:00:07,150 tidy package of information about something you want to use in your code. 4 00:00:07,150 --> 00:00:09,510 This package contains a group of properties and 5 00:00:09,510 --> 00:00:13,054 functions that work together to represent something in your program. 6 00:00:14,455 --> 00:00:17,154 As a reminder, an object's properties are a series of 7 00:00:17,154 --> 00:00:19,985 key value pairs that hold information about the object. 8 00:00:19,985 --> 00:00:22,655 And its functions are called methods. 9 00:00:22,655 --> 00:00:26,997 Methods let your object do something or let something be done to it. 10 00:00:26,997 --> 00:00:31,192 The term object oriented programming is really just describing a programming 11 00:00:31,192 --> 00:00:32,285 paradigm. 12 00:00:32,285 --> 00:00:37,149 Or a way of thinking about in designing a computer program that uses objects 13 00:00:37,149 --> 00:00:38,007 as its core. 14 00:00:38,007 --> 00:00:41,993 A lot of developers find it helpful to think of object's in a code as a way to 15 00:00:41,993 --> 00:00:43,940 model real life objects. 16 00:00:43,940 --> 00:00:47,630 Real life objects have states and behaviors and so the JavaScript objects. 17 00:00:47,630 --> 00:00:51,553 In JavaScript states are represented by the object's properties and 18 00:00:51,553 --> 00:00:55,320 behaviors are represented by the object's methods. 19 00:00:55,320 --> 00:00:57,502 So if we were helping to represent a house in our code. 20 00:00:57,502 --> 00:01:03,770 We can make a house object with properties like square footage, color and year built. 21 00:01:03,770 --> 00:01:05,530 Or if we wanna to model a radio. 22 00:01:05,530 --> 00:01:09,930 We could make a radio object with properties like station and volume and 23 00:01:09,930 --> 00:01:12,510 methods like turn off or change station. 24 00:01:13,860 --> 00:01:17,044 Just like these object's states can be changed in real life, 25 00:01:17,044 --> 00:01:19,281 we can paint a house or build an addition. 26 00:01:19,281 --> 00:01:21,860 Tune a radio or increase the volume. 27 00:01:21,860 --> 00:01:26,204 We can change these states in our code by updating an object's properties. 28 00:01:26,204 --> 00:01:27,393 The idea of mimicking or 29 00:01:27,393 --> 00:01:31,375 modelling real life objects is a pretty good way to try and think about objects, 30 00:01:31,375 --> 00:01:34,990 properties and methods when we're first learning about them. 31 00:01:34,990 --> 00:01:37,945 But it's not always super realistic. 32 00:01:37,945 --> 00:01:43,250 Sometimes we are trying to model real life objects like houses or radios in our code. 33 00:01:43,250 --> 00:01:46,262 But more often, our objects are a little more abstract or 34 00:01:46,262 --> 00:01:49,227 less analogous to things we might use in everyday life. 35 00:01:49,227 --> 00:01:53,304 Most of the time when we design objects we're creating an easy way to store 36 00:01:53,304 --> 00:01:56,340 information about something via properties. 37 00:01:56,340 --> 00:02:00,390 And access, manipulate or utilize that information via methods. 38 00:02:00,390 --> 00:02:05,116 These objects are more like data containers than abstractions of real 39 00:02:05,116 --> 00:02:06,165 life objects. 40 00:02:06,165 --> 00:02:09,610 When I build apps, I've created objects to help me manage things like users. 41 00:02:09,610 --> 00:02:14,490 Some of the properties were username, birthday, status and number of friends. 42 00:02:14,490 --> 00:02:17,681 The methods were addFriend() and updateStatus(). 43 00:02:17,681 --> 00:02:21,378 I've also built simple games where I used an object to store information about 44 00:02:21,378 --> 00:02:22,210 the game state. 45 00:02:22,210 --> 00:02:26,680 Like the score and whose turn it was and other objects to represent the players. 46 00:02:26,680 --> 00:02:30,508 I've also used objects when building API wrappers to share on GitHub with 47 00:02:30,508 --> 00:02:32,670 fellow programmers. 48 00:02:32,670 --> 00:02:36,863 This is some pretty conceptual stuff and right now it might not be super obvious 49 00:02:36,863 --> 00:02:40,117 why objects are so useful or how you'd use them in practice. 50 00:02:40,117 --> 00:02:41,420 Don't worry. 51 00:02:41,420 --> 00:02:44,606 As we move through this course, we'll cover all the ways that objects can help 52 00:02:44,606 --> 00:02:46,260 you reduce the amount of code you write. 53 00:02:46,260 --> 00:02:49,244 Make your code easier to maintain and modify and 54 00:02:49,244 --> 00:02:52,757 help you create a code base that's easy to understand. 55 00:02:52,757 --> 00:02:56,533 A fun fact you may not know, is that if you've been using JavaScript, 56 00:02:56,533 --> 00:02:58,970 you've been using objects all along. 57 00:02:58,970 --> 00:03:02,889 And you probably already have a pretty good innate understanding of that. 58 00:03:02,889 --> 00:03:05,607 In the next video, we are going to explore that further, and 59 00:03:05,607 --> 00:03:09,830 take a look at some objects you're already really familiar with, like arrays. 60 00:03:09,830 --> 00:03:13,314 This should help you get a clear picture of how useful objects are and 61 00:03:13,314 --> 00:03:15,283 why you might want to create your own. 62 00:03:15,283 --> 00:03:16,403 Later on in the course, 63 00:03:16,403 --> 00:03:20,110 we'll start digging into not only the actual syntax of how we create objects. 64 00:03:20,110 --> 00:03:24,230 But you'll also start training you brain to think about object design. 65 00:03:24,230 --> 00:03:26,957 And how and when you should use them in your apps. 66 00:03:26,957 --> 00:03:29,340 Come join me in the next video and I'll see you soon.