-
Notifications
You must be signed in to change notification settings - Fork 9
/
May_18.js
72 lines (57 loc) · 1.72 KB
/
May_18.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
// let friend1 = 'Deepa';
// let friend2 = 'Naina';
// let friend3 = 'Dipanshu';
// let friend4 = 'Sakib';
// let friend5 = 'Himanshu';
// let friend6 = 'Jasleen';
// let friend7 = 'Navneet';
// let friend8 = 'Nishant';
// let friendArray = ['Deepa','Naina','Dipanshu','Sakib','Nishant'];
// //0 1 2 3 4
// // console.log(friendArray.length); //5
// //arrayname[index]
// for(var i=0; i < friendArray.length;i++){
// console.log(greet(friendArray[i]))
// }
// function greet(friendName){
// let msg = `Hey, ${friendName} today is my birthday
// you are invited`;
// return msg;
// }
// console.log(greet(friend1))
// console.log(greet(friend2))
// console.log(greet(friend3))
/////////// DECLARING AN ARRAY =============
// 1. Literal way
// var arrName = [1,2,"hi"];
// console.log(arrName);
// // 2. Using new keyword // Constructral declaration
// var newArray = new Array(4,5);
// console.log(arrName[1] / newArray[1]);
//single dimension array
// var arr = [19,23,42,21];
// // 0 1 2 3
// console.log(arr[2])
// //multidimension array
// var arr1 = [["hi","Nilanjan"], [12,"ipsum",{"name":"Parag"}]]
// // // 0 1
// // // 0 1 0 1 2
// for(i=0; i<arr1.length; i++)
// {
// var innerElem = arr1[0];
// for(inner=0;inner<innerElem.length;inner++){
// console.log(arr1[i][inner])
// }
// }
//=============================Object ==============================
// Declaration
//Type 1: Literal way
//keys and values
var pen = {
"make": "Parker",
"cost": "500"
}
console.log(pen)
//Type 2 : Object create method
var penCopy = Object.create(pen)
console.log(penCopy)