Skip to content

Commit

Permalink
Add space before assignment operator in Working with objects js guide (
Browse files Browse the repository at this point in the history
  • Loading branch information
digi-booster authored Sep 27, 2021
1 parent 9e3a809 commit 6d4fbc7
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ var obj = { property_1: value_1, // property_# may be an identifier...
'property n': value_n }; // or a string
```

where `obj` is the name of the new object, each `property_i` is an identifier (either a name, a number, or a string literal), and each `value_i` is an expression whose value is assigned to the `property_i`. The `obj` and assignment is optional; if you do not need to refer to this object elsewhere, you do not need to assign it to a variable. (Note that you may need to wrap the object literal in parentheses if the object appears where a statement is expected, so as not to have the literal be confused with a block statement.)
where `obj` is the name of the new object, each `property_i` is an identifier (either a name, a number, or a string literal), and each `value_i` is an expression whose value is assigned to the `property_i`. The `obj` and assignment are optional; if you do not need to refer to this object elsewhere, you do not need to assign it to a variable. (Note that you may need to wrap the object literal in parentheses if the object appears where a statement is expected, so as not to have the literal be confused with a block statement.)

Object initializers are expressions, and each object initializer results in a new object being created whenever the statement in which it appears is executed. Identical object initializers create distinct objects that will not compare to each other as equal. Objects are created as if a call to `new Object()` were made; that is, objects made from object literal expressions are instances of `Object`.

Expand Down Expand Up @@ -385,7 +385,7 @@ const Manager = {
  age: 27,
  job: "Software Engineer"
}
const Intern= {
const Intern = {
  name: "Ben",
  age: 21,
  job: "Software Engineer Intern"
Expand All @@ -403,7 +403,7 @@ Manager.sayHi() // Hello, my name is John'
Intern.sayHi() // Hello, my name is Ben'
```

The `this` refers to the object that it is in. You can create a new function called `howOldAmI()`which logs a sentence saying how old the person is.
The `this` refers to the object that it is in. You can create a new function called `howOldAmI()` which logs a sentence saying how old the person is.

```js
function howOldAmI (){
Expand Down

0 comments on commit 6d4fbc7

Please sign in to comment.