-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPractise.js
More file actions
64 lines (56 loc) · 1.22 KB
/
Practise.js
File metadata and controls
64 lines (56 loc) · 1.22 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
// const array = [1, 2, 3, 4];
// for (var i = 0; i < array.length; i++) {
// setTimeout(function () {
// console.log("I am at index " + i);
// }, 3000);
// }
// //
// setTimeout(() => {
// for (var i = 0; i < array.length; i++) {
// console.log("I am at index " + i);
// }
// }, 3000);
// //
// const array = [1, 2, 3, 4];
// for (var i = 0; i < array.length; i++) {
// (function (clouserI) {
// setTimeout(function () {
// console.log("I am at index " + clouserI);
// }, 3000);
// })(i);
// }
// const array = [1, 2, 3, 4];
// for (let i = 0; i < array.length; i++) {
// setTimeout(function () {
// console.log("I am at index " + i);
// }, 3000);
// }
//
new Date("1900-10-10").lastYear();
// "1899"
//Solution
Date.prototype.lastYear = function() ={
console.log(this);
return this.getFullYear() - 1;
};
// 2nd Solution
Array.prototype.map = function () {
let arr =[];
for(let i=0; i<this.length; i++){
arr.push((this[i] + "🗺️"))
}
return arr;
}
console.log([1,2,3].map())
// ['1🗺️', '2🗺️', '3🗺️']
//
const obj1 = {
name: "Bob",
age: 22
}
const obj2 = {
name: "Bob",
age: 22
}
console.log(obj1 === obj2);
console.log(JSON.stringify(obj1) === JSON.stringify(obj2));