File tree 4 files changed +19
-8
lines changed
4 files changed +19
-8
lines changed Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
- const f1 = ( ...args ) => console . log ( args ) ;
3
+ const f1 = ( ...args ) => {
4
+ console . log ( args ) ;
5
+ } ;
4
6
5
7
f1 ( 1 , 2 , 3 ) ;
6
8
7
9
const f2 = ( ...args ) => {
8
10
args . forEach ( arg => {
11
+ console . log ( 'Type: ' + typeof ( arg ) ) ;
9
12
if ( typeof ( arg ) === 'object' ) {
10
- console . log ( typeof ( arg ) + ' : ' + JSON . stringify ( arg ) ) ;
13
+ console . log ( 'Value : ' + JSON . stringify ( arg ) ) ;
11
14
} else {
12
- console . log ( typeof ( arg ) + ' : ' + arg ) ;
15
+ console . log ( 'Value : ' + arg ) ;
13
16
}
14
17
} ) ;
15
18
} ;
Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
3
const obj1 = {
4
- f1 : function inc ( a ) {
4
+ fn1 : function inc ( a ) {
5
5
return ++ a ;
6
6
} ,
7
7
sum : function ( a , b ) {
@@ -20,11 +20,14 @@ const obj1 = {
20
20
}
21
21
} ;
22
22
23
- console . log ( 'obj1.f1 .name = ' + obj1 . f1 . name ) ;
23
+ console . log ( 'obj1.fn1 .name = ' + obj1 . fn1 . name ) ;
24
24
console . log ( 'obj1.sum.name = ' + obj1 . sum . name ) ;
25
+ console . log ( 'obj1.inc.name = ' + obj1 . inc . name ) ;
25
26
console . log ( 'obj1.max.name = ' + obj1 . max . name ) ;
27
+ console . log ( 'obj1.min.name = ' + obj1 . min . name ) ;
28
+ console . log ( 'obj1.dec.name = ' + obj1 . dec . name ) ;
26
29
27
- console . log ( 'obj1.f1 (5) = ' + obj1 . f1 ( 5 ) ) ;
30
+ console . log ( 'obj1.fn1 (5) = ' + obj1 . fn1 ( 5 ) ) ;
28
31
console . log ( 'obj1.sum(1, 3) = ' + obj1 . sum ( 1 , 3 ) ) ;
29
32
console . log ( 'obj1.max(8, 6) = ' + obj1 . max ( 8 , 6 ) ) ;
30
33
Original file line number Diff line number Diff line change @@ -8,8 +8,12 @@ const city = {
8
8
} ,
9
9
f2 : ( ) => {
10
10
return this . name ;
11
+ } ,
12
+ f3 ( ) {
13
+ return this . name ;
11
14
}
12
15
} ;
13
16
14
17
console . log ( 'city.f1() = ' + city . f1 ( ) ) ;
15
18
console . log ( 'city.f2() = ' + city . f2 ( ) ) ;
19
+ console . log ( 'city.f3() = ' + city . f3 ( ) ) ;
Original file line number Diff line number Diff line change @@ -7,5 +7,6 @@ function f1(a, b) {
7
7
f1 ( 2 , 3 ) ;
8
8
f1 . call ( null , 2 , 3 ) ;
9
9
10
- f1 ( ...[ 2 , 3 ] ) ;
11
- f1 . apply ( null , [ 2 , 3 ] ) ;
10
+ const arr = [ 2 , 3 ] ;
11
+ f1 ( ...arr ) ;
12
+ f1 . apply ( null , arr ) ;
You can’t perform that action at this time.
0 commit comments