Start Using THIS JavaScript Feature! #shorts
Goose - The Coding Cat
This is a JavaScript feature that's not super well known, but it's actually super useful. So here we have a user object with the name a birthday and an age. This age is correct. We can see it logs out 25, but in a year's time this age won't be correct anymore and we would have to remember to update it. So what we can do instead of using an age property is we can use a different property so we can say git and then age. And this is going to work just like a standard method, but also sort of like a standard property. So now what we can do is we can paste in some code to calculate the age based on the birthday. And now we can still use this age as a property. So when I console log out user age, it's actually going to call this method that we just added.
#coding #javascript #short #codingshort #javascriptshorts #shortsjavascript #html #css #in49seconds ... https://www.youtube.com/watch?v=-bkEZHzRvrI
1192922 Bytes