zzz6519003 / blog

My blog about coding
4 stars 1 forks source link

A Look at JavaScript Object Prototypes #121

Open zzz6519003 opened 5 years ago

zzz6519003 commented 5 years ago

“A prototype is another object that is used as a fallback source of properties. When an object gets a request for a property that it does not have, its prototype will be searched for the property, then the prototype’s prototype, and so on.”

zzz6519003 commented 5 years ago

“A prototype can be used at any time to add new properties and methods to all objects based on it.”

zzz6519003 commented 5 years ago

“One way to create an object is by using a curly brace notation. […] Inside the curly braces, we can give a list of properties separated by commas. Each property is written as a name, followed by a colon, followed by an expression that provides a value for the property. […] Properties whose names are not valid variable names or valid numbers have to be quoted.”

zzz6519003 commented 5 years ago

Lesson learned: object properties can be named pretty much anything you want! And all objects inherit properties and methods from their prototypes. There’s much more to learn, but I think now I might know just enough to tackle the next exercism.io practice problem! Maybe I can give that a try tomorrow.