Skip to content

Commit 03e9df2

Browse files
committed
JavaScript 101 Types: Removed new Object
1 parent e0f2a74 commit 03e9df2

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

page/javascript-101/types.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,17 @@ Everything else in JavaScript is considered an object. While there are [numerous
7373
* Array
7474
* Function
7575

76-
The simplest way to create an object is either through the `Object` constructor or the shorthand syntax known as object literal. These simple objects are unordered key/value pairs. The key is formally known as a property and the value can be any valid JavaScript type, even another object. To create or access a property on an object, we use what is known as "dot notation" or "bracket notation."
76+
The simplest way to create an object is the shorthand syntax known as object literal. These simple objects are unordered key and value pairs. The key is formally known as a *property* and the value can be any valid JavaScript type, even another object. To create or access a property on an object, we use what is known as "dot notation" or "bracket notation."
7777

7878
```
79-
// Creating an object with the constructor:
80-
var person1 = new Object;
79+
// Using an empty object literal
80+
var person1 = {};
8181
82+
// Assign properties using "dot notation"
8283
person1.firstName = "John";
8384
person1.lastName = "Doe";
8485
86+
// Access properties using "dot notation"
8587
alert( person1.firstName + " " + person1.lastName );
8688
8789
// Creating an object with the object literal syntax:
@@ -91,20 +93,20 @@ var person2 = {
9193
};
9294
9395
alert( person2.firstName + " " + person2.lastName );
94-
```
9596
96-
```
97-
// As mentioned, objects can also have objects as a property.
9897
var people = {};
9998
99+
// Assign properties using "bracket notation"
100+
// As mentioned, objects can also have objects as a property value
100101
people[ "person1" ] = person1;
101102
people[ "person2" ] = person2;
102103
104+
// Access properties using a mix of both bracket and dot notation
103105
alert( people[ "person1" ].firstName );
104106
alert( people[ "person2" ].firstName );
105107
```
106108

107-
If a property is accessed that has not been defined, it will return a type of `undefined`.
109+
If a property is accessed that has not been defined, it will have the value `undefined`.
108110

109111
```
110112
// Properties that have not been created are undefined.

0 commit comments

Comments
 (0)