-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnonPremitive.js
More file actions
80 lines (61 loc) · 1.84 KB
/
nonPremitive.js
File metadata and controls
80 lines (61 loc) · 1.84 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// non premitive data types
// Array ( number of data that is of same data type)
// var fullName = ["Aditya", "Dhanraj", 2];
// console.log(fullName)
// fullName.push("hi")
// console.log(fullName)
// // map function
// fullName.map((name) => {
// console.log(name)
// }); // like for each loop
// objects (key value pair)
// var userData = {
// name: "Aditya Dhanraj", // key cannot be duplicate
// age: 20,
// married: false,
// friends: ["tannu","rishika","abhinav"],
// "full name" : "Dev town" // this is when space is required
// }
// console.log(userData)
// console.log(userData.friends)
// console.log(userData.age)
// console.log(userData["full name"])
// combination of array and object
// array of objects
// var studentsData = [
// {
// name: "Aditya"
// },
// {
// name: "Dhanraj"
// },
// {
// name: "Raj"
// }
// ];
// console.log(studentsData)
// studentsData.map((data) => console.log(data.name))
// var data = {
// name : "Aditya",
// class: "12th"
// };
// data.age = 12; // using this we can add new field in it
// data.name = "Aditya Dhanraj"; // we can update the field
// data.class = undefined; // can set it to undefined
// console.log(data)
// String manipulation
var name = "adiTya";
console.log(name.toUpperCase());
console.log(name.toLowerCase());
console.log(name.slice(0,3)); // from 0 to 3-1
var cote = "Javascript is amazing";
console.log(cote.replace("Javascript","JS")) // only replace the first word
console.log(cote)
console.log(cote.includes("is"));
var stringNumber = "23412"
var number = parseInt(stringNumber);
console.log(number+1);
var string = "12w3";
console.log(parseInt(string)); // upto where number is, it will parse
var String = "adsjsad";
console.log(parseInt(String)); // it will give Nan(Not a number) because it cannot be parsed