-
Notifications
You must be signed in to change notification settings - Fork 0
/
annotations2.js
57 lines (49 loc) · 974 Bytes
/
annotations2.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
*************
** Objects **
*************
*/
function person(name, age, nickname) {
this.name = namee;
this.age = age;
this.nickname = nickname;
this.present = function() {
console.log(`Hello, I am ${this.name}, but you can call me ${this.nickname}. Oh, and I am %{this.age} years old.`)
}
}
var felix = person('Gabriel', 22, 'Felix')
felix.present()
/*
* 'Hello, I am Gabriel, but you can call me
* Felix. Oh, and I am 22 years old.'
*/
var felix = {
name : 'Gabriel',
nickname : 'Felix',
age : 22,
}
/*
************
** Arrays **
************
*/
var array1 = [1, 2, 3]
var array2 = new Array(1, 2, 3)
var array3 = new Array(3)
array3[0] = 1
array3[1] = 2
array3[2] = 3
array1.length // 3
array2.concat(array3) // [1, 2, 3, 1, 2, 3]
/*
***************
** Variables **
***************
*
* / const >> imutable
* / var >> global scope
* / let >> local scope
*/
var a = 10;
const b = 'hello';
let c = true;