the-modern-javascript-bootcamp/notes/chapter5_javascript-objects.md

29 lines
976 B
Markdown
Raw Normal View History

2021-01-19 21:40:05 +11:00
# Chapter 5: JavaScript Objects
## Object Basics
Create objects:
```js
let object_name = {
property_1_name: property1_value,
property_2_name: property2_value,
}
```
To access a single property, using `.` (dot) operator
Check code in [object-101.js](../src/objects/objects-101.js)
## Using Objects with Functions
Parse objects into function just like normal number, it allow us to parse multiple values into function as a single value. Or get multiple values as single value from a function
Exmple check [object-function.js](../src/objects/objects-functions.js)
2021-01-19 22:06:43 +11:00
## Object References
When a object is parsed as argument into function, it's parsed as reference (not as a copy). Changes done by function on object affect original object
But when a new value to the argument (in function), it break the binding (pass as reference) within function. But does not affect the original object
Example check [object-references.js](../src/objects/objects-references.js)