-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharray.ts
More file actions
39 lines (31 loc) · 1.11 KB
/
array.ts
File metadata and controls
39 lines (31 loc) · 1.11 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
// //properties
// let arr: string[] = ["apple", "banana", "orange", "mango"];
// console.log(arr.length);
// let a :number=arr.length
// console.log(a);
// //ACCESSING THE ELEMENT OF ARRAY
// console.log(arr[1]);
// //ACCESSING THE all ELEMENT OF ARRAY
// console.log(arr);
// //we can use this method to store diifernt types of data types in an array
// let arr2 : (string|number|boolean)[]=["apple","banana","orange","mango",4,5,true];
// console.log(arr2);
// // to change the element of an array by its index number
// arr[0] = "kiwi";
// console.log(arr);
// //(Array Destructuring) store an array elements in different varaibles
// let arr3:number[]=[1,2,3,4]
// let [a,b,c] = arr3
// console.log(a);
// console.log(b);
// console.log(c);
// console.log(arr3);
// let a =arr3[0]
// let b = arr3[2]
// console.log(a,b);
// //array destructing using rest operator
// let arr4:number[]=[1,2,3,4]
// let [a , ...rest]= arr4 //rest is not a keyword we can use any word
// console.log(a);
// console.log(rest);
// //Methods