File tree 1 file changed +21
-19
lines changed
1 file changed +21
-19
lines changed Original file line number Diff line number Diff line change @@ -10,28 +10,30 @@ called a method of the object. Otherwise, they are called properties.
10
10
As it turns out, nearly everything in JavaScript is an object -- arrays,
11
11
functions, numbers, even strings -- and they all have properties and methods.
12
12
13
- <javascript caption =" Creating an object literal " >
14
- var myObject = {
15
- sayHello : function() {
16
- console.log('hello');
17
- },
18
- myName : 'Rebecca'
19
- };
20
-
21
- myObject.sayHello(); // logs 'hello'
22
-
23
- console.log(myObject.myName); // logs 'Rebecca'
24
- </javascript >
13
+ ``` js
14
+ // Creating an object literal
15
+ var myObject = {
16
+ sayHello : function () {
17
+ console .log (' hello' );
18
+ },
19
+ myName : ' Rebecca'
20
+ };
21
+
22
+ myObject .sayHello (); // logs 'hello'
23
+
24
+ console .log (myObject .myName ); // logs 'Rebecca'
25
+ ```
25
26
26
27
27
28
When creating object literals, you should note that the key portion of each
28
29
key-value pair can be written as any valid JavaScript identifier, a string
29
30
(wrapped in quotes) or a number:
30
31
31
- <javascript caption =" test " >
32
- var myObject = {
33
- validIdentifier : 123,
34
- 'some string' : 456,
35
- 99999 : 789
36
- };
37
- </javascript >
32
+ ``` js
33
+ // test
34
+ var myObject = {
35
+ validIdentifier : 123 ,
36
+ ' some string' : 456 ,
37
+ 99999 : 789
38
+ };
39
+ ```
You can’t perform that action at this time.
0 commit comments