-
Notifications
You must be signed in to change notification settings - Fork 1
/
app2.js
113 lines (70 loc) · 1.95 KB
/
app2.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
// const person = {
// age: 12,
// name:'reza'
// }
// const student ={
// level:8
// }
// Object.setPrototypeOf(student,person);
// // const student = Object.create(person);
// // student.level = 18;__proto__
// //propotype
// //console.log(person.__proto__.hasOwnProperty('hasOwnProperty'));
// // console.log(student.__proto__.__proto__);
// const age = 21;
// const lastname = "hasanzade";
// const lastname2 = String("hasanzade");
// // String
// // Number
// // Boolean
// console.log('age' in student);
// const myarray = ["0",1,false,{name:'asdasd'},[4,56,0]]
// console.log(myarray[4][2]);
//Mutator =>
//Accessor => array
//Itrator => void
// const arr = [2,4,1,4,65,0];
// console.log(arr);
// arr.sort(function (a,b){
// return b - a
// });
// arr.push(66);
// console.log(arr);
// const removedItem = arr.pop();
// console.log(removedItem);
// console.log(arr);
// arr.unshift(99);
// console.log(arr);
// const removedItem2 = arr.shift();
// console.log(removedItem2);
// console.log(arr);
// // const arr2 = ["ali","reza","morad","bahman","azar"];
// // console.log(arr2);
// // arr.sort(function (a,b){
// // if (b - a > 0) return 1;
// // if (a - b < 0) return -1;
// // if (a - b == 0) return 0;
// // });
// console.log(arr);
// const arr2 = [2,4,1,4,65,0];
// arr2.splice(2,1);
// console.log(arr2);
// const array1 = [{name:'ali'},{name:'reza'},{name:'morad'}];
// const array2 = array1.slice();
// array1[0].name = 'kazem';
// console.log('-----');
// console.log(array1);
// console.log(array2);
///----
const arr2 = ["ali","reza","maryam","morad","bahman","azar"];
const arr3 = ["maryam"];
const result = arr2.concat(arr3);
// console.log(result.lastIndexOf("maryam"));
// console.log(result.indexOf("maryam"));
console.log(result);
const sliced = result.slice();
console.log(sliced);
const joinsample = result.join(' ~ ');
const str = joinsample.split(' ~ ')
console.log(joinsample);
console.log(str);