You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 08_Day/08_day_objects.md
+16-14Lines changed: 16 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,12 +17,12 @@
17
17
18
18

19
19
20
-
-[📔 Day 8](#%f0%9f%93%94-day-8)
20
+
-[📔 Day 8](#-day-8)
21
21
-[Scope](#scope)
22
22
-[Window Scope](#window-scope)
23
23
-[Global scope](#global-scope)
24
24
-[Local scope](#local-scope)
25
-
-[📔 Object](#%f0%9f%93%94-object)
25
+
-[📔 Object](#-object)
26
26
-[Creating an empty object](#creating-an-empty-object)
27
27
-[Creating an objecting with values](#creating-an-objecting-with-values)
28
28
-[Getting values from an object](#getting-values-from-an-object)
@@ -33,9 +33,10 @@
33
33
-[Getting object values using Object.values()](#getting-object-values-using-objectvalues)
34
34
-[Getting object keys and values using Object.entries()](#getting-object-keys-and-values-using-objectentries)
35
35
-[Checking properties using hasOwnProperty()](#checking-properties-using-hasownproperty)
36
-
-[💻 Exercises](#%f0%9f%92%bb-exercises)
36
+
-[💻 Exercises](#-exercises)
37
37
-[Exercises: Level 1](#exercises-level-1)
38
38
-[Exercises: Level 2](#exercises-level-2)
39
+
-[Exercises: Level 3](#exercises-level-3)
39
40
40
41
# 📔 Day 8
41
42
@@ -72,7 +73,7 @@ console.log(a, b) // accessible
72
73
73
74
### Global scope
74
75
75
-
A globally declared variable can be access every where in the same file. But the term global is relative. It can be global to the file or it can be global relative to some block of codes.
76
+
A globally declared variable can be accessed every where in the same file. But the term global is relative. It can be global to the file or it can be global relative to some block of codes.
76
77
77
78
```js
78
79
//scope.js
@@ -93,7 +94,7 @@ console.log(a, b) // JavaScript 10, accessible
93
94
94
95
### Local scope
95
96
96
-
A local declared variable can be access only certain block code.
97
+
A variable declared as local can be accessed only in certain block code.
97
98
98
99
```js
99
100
//scope.js
@@ -117,7 +118,7 @@ letsLearnScope()
117
118
console.log(a, b) // JavaScript 10, accessible
118
119
```
119
120
120
-
Now, you have an understanding of scope. A variable declared with *var* only scoped to function but variable declared with *let* or *const* is block scope(function block, if block, loop etc)
121
+
Now, you have an understanding of scope. A variable declared with *var* only scoped to function but variable declared with *let* or *const* is block scope(function block, if block, loop etc). Block in JavaScript is a code in between two curly brackets ({}).
121
122
122
123
```js
123
124
//scope.js
@@ -141,7 +142,7 @@ console.log(i)
141
142
142
143
```
143
144
144
-
In ES6 and above there is *let* and *const*, so you will suffer from the sneakiness of *var*. When we use *let* our variable is block scope and it will not infect other parts of our code.
145
+
In ES6 and above there is *let* and *const*, so you will not suffer from the sneakiness of *var*. When we use *let* our variable is block scoped and it will not infect other parts of our code.
145
146
146
147
```js
147
148
//scope.js
@@ -166,12 +167,12 @@ for(let i = 0; i < 3; i++){
166
167
167
168
```
168
169
169
-
The scope *let* and *const* is the same. The difference is only reassigning. We can not change or reassign the value of const variable. I would strongly suggest you to use *let* and *const*, by using *let* and *const* you will writ clean code and avoid hard to debug mistakes. As a rule of thumb, you can use *let* for any value which change, *const* for any constant value, array, object, arrow function and function expression.
170
+
The scope *let* and *const* is the same. The difference is only reassigning. We can not change or reassign the value of const variable. I would strongly suggest you to use *let* and *const*, by using *let* and *const* you will writ clean code and avoid hard to debug mistakes. As a rule of thumb, you can use *let* for any value which change, *const* for any constant value, and for array, object, arrow function and function expression.
170
171
171
172
## 📔 Object
172
173
173
-
Everything can be an object and objects do have properties and properties have values, so an object is key value pair. The order of the key is not reserved, or there is no order.
174
-
Creating an object literal. To create an object literal, we use two curly brackets.
174
+
Everything can be an object and objects do have properties and properties have values, so an object is a key value pair. The order of the key is not reserved, or there is no order.
175
+
To create an object literal, we use two curly brackets.
175
176
176
177
### Creating an empty object
177
178
@@ -185,7 +186,7 @@ const person = {}
185
186
186
187
Now, the person object has firstName, lastName, age, location, skills and isMarried properties. The value of properties or keys could be a string, number, boolean, an object, null, undefined or a function.
187
188
188
-
Let us see some examples of object. Each key has a value in object.
189
+
Let us see some examples of object. Each key has a value in the object.
0 commit comments