-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathindex.js
More file actions
79 lines (58 loc) · 1.43 KB
/
index.js
File metadata and controls
79 lines (58 loc) · 1.43 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
class Person {
constructor (name, family) {
this.name = name
this.family = family
}
static country = 'Iran'
static hi () {
console.log(this)
console.log('Hi')
}
hello () {
console.log(this)
}
}
const ali = new Person('Ali', 'Mousavi')
console.log(ali.country)
console.log(Person.country)
console.log(Person.family)
Person.hi()
ali.hello()
// ali.hi()
// const person = {
// name: 'Ali',
// family: 'Mousavi',
// age: 32,
// [Symbol.toPrimitive] (hint) {
// console.log(hint)
// if (hint === 'string') {
// return `${this.name} ${this.family}`
// }
// if (hint === 'number') {
// return this.age
// }
// }
// }
// console.log(`My Name is ${person}. and I have ${+person} years old`)
// const sym1 = Symbol.for('ali')
// const sym2 = Symbol.for('ali')
// console.log(sym1 === sym2)
// const sym1 = Symbol()
// const sym2 = Symbol()
// console.log(sym1 === sym2)
// console.log(sym1 === sym1)
// const addressSymbol = Symbol('address')
// const person = {
// name: 'Ali',
// family: 'Mousavi',
// [addressSymbol]: 'Shiraz'
// }
// for (const key in person) {
// console.log(key, person[key])
// }
// console.log(JSON.stringify(person))
// console.log(person.addressSymbol) // wrong
// console.log(person[addressSymbol]) // ok
// fetch('https://jsonplaceholder.typicode.com/users')
// .then(response => response.json())
// .then(data => console.log(data))