-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
79 lines (59 loc) · 1.19 KB
/
index.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*let person = {
name: 'Shakib',
age: 27
};
//Dot Notation
person.name = 'Hossan';
//Bracker notation
person['name'] = 'Mary';
console.log(person.name);
*/
/*let selectedColors = ['red', 'blue'];
selectedColors[2] = 1;
console.log(selectedColors);
function greet(name, lastName) {
console.log('Hello ' + name +' ' + lastName);
}
//calculating a value
function square(number){
return number*number;
}
console.log(square(2));
//Factory Function
function createCircle(radius) {
return {
radius,
draw: function() {
console.log('draw');
}
};
}
const circle = createCircle(1);
//Constructor Function
function Circle(radius) {
this.radius = radius;
this.draw = function(){
console.log('draw');
}
}
Circle.call({}, 1)
Circle.apply({},[ 1, 2, 3]);
const another = new Circle(1);
let obj = { value: 10};
function increase(obj) {
obj.value++;
console.log(obj);
}
increase(obj);
console.log(obj);
*/
function Circle(radius) {
this.radius = radius;
this.draw = function() {
console.log('draw');
}
}
const circle = new Circle(10);
circle.location = { x: 1};
const propertyName = 'location';
circle[propertyName] = {x: 1};