02Geek HTML5 and JavaScript, TypeScript, React, Flash, ActionScript online School
Previous VideoNext Video

Properties and Methods

We explore properties and methods and find their relationship to variables and functions.

Video Transcript

00:00Until now we worked with with our objects and we kind of assumed that these
00:06variables that we created are variables and and it's not a bad assumption but
00:11there's a small difference between a variable that we defined right here
00:15let's say for example we define here a variable which we'll call ID which I
00:22your ID would be a string let's say and it would be just some random ID right
00:28let's say that's an ID and if we create our object and create a new equals new
00:39object open close bracket now if we create if we added our ID a new ID into
00:47our object we're gonna give it a new ID and call it Ben's ID and it it's true
00:56this is a type of string and this is a type of string right if you get try to
01:02think what is the difference between them the difference is very minute but
01:06it's a big one the difference between a variable which this is a variable and
01:10this is a property a property is called a property because it belongs to the
01:15object is a property a type of variable it is yeah but it's a variable that
01:20belongs to an object and it's you know it's one of those terminologies that
01:25it's important to know them just because as you read different books or
01:30you read things online or maybe Adobe helped files and so on sometimes they'll
01:36use variables sometimes they'll use properties but for most scenarios it's
01:42exactly the same thing the only time where you really care about it is when
01:45you're actually a property you know the property belongs to an object well a
01:49variable doesn't necessarily belong to anything same thing for methods and
01:55functions so first of all we've seen functions before right we've seen how we
02:00created a function let's quick function here let's say we're gonna call it um
02:05hello and it would return a string and I'm gonna trace out here hello oh we want
02:20to return return hello right because we're returning a string we have our
02:26function hello now our function is kind of a standalone function and that's why
02:31it's called a function it doesn't belong to any object although on the other hand
02:38our object if you just type oh and click type dot we're gonna see that our
02:42object has a lot of different functions associated with it for example the two
02:47string function what does the two string function do it returns a string
02:52representation of our object and if I just grab our two string and I just
02:59trace out our two string we should be getting here a weird type of message
03:06which tells us object object which basically just says trace out an object
03:11that's what you get it's not a very useful method right now in our base
03:16object but it's a very very useful object very very useful method in other
03:22types of objects and this method is in everything in flash and if you're when I
03:29say everything I really mean everything and to prove that we could even go to
03:34our string so let's go to our ID dot to string them our string has even a two
03:44string and if I trace out our two string to string our ID to string we're
03:53going to get a value back over actually the value itself of our string now if
03:58you're wondering why does everything have a two string even when it's not
04:01relevant the reason is is because as we said before everything is an object in
04:05flash and actually all the base functions and properties of an object
04:10all this stuff that come inside of the object in default will be in every
04:15single variable and object every single object type in flash and everything is
04:20an object type in flash thus everything should have a two string method
04:24associated with it so we talked about properties and variables and the
04:30difference between them we talked about methods and functions and the
04:34differences between them and as we've done that we've noticed that objects and
04:39any object for that matter all come with a preset amount of predefined
04:45functions or methods more accurately

Ready to Level Up Your Skills?

Join thousands of learners on 02GEEK and start your journey to becoming a coding expert today!

Enroll Now for Free!