FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Basic-To-Advanced-JavaScript/Object/app.js at main · MaazWebDev/Basic-To-Advanced-JavaScript · GitHub
MaazWebDev
/
Basic-To-Advanced-JavaScript
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Basic-To-Advanced-JavaScript
/
Object
/
app.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
122 lines (103 loc) · 2.88 KB
Breadcrumbs
Basic-To-Advanced-JavaScript
/
Object
/
app.js
Copy path
File metadata and controls
122 lines (103 loc) · 2.88 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
112
113
114
115
116
117
118
119
120
121
122
//Object
//object is a collection of properties ,
//property consist of name/key and value
//if property value is function , it is called method
var
keyboard
=
{
company
:
"Logitics"
,
//string
color
:
"Black"
,
//string
price
:
400
,
//number
isNew
:
false
,
//boolean
getDiscountedValue
:
function
(
disc
)
{
console
.
log
(
"This==>"
,
this
)
;
var
discount
=
(
this
.
price
*
disc
)
/
100
;
console
.
log
(
"Discount=>"
,
discount
)
;
var
discountedPrice
=
this
.
price
-
discount
;
return
discountedPrice
;
}
,
}
;
// add object property
keyboard
.
type
=
"memrein"
;
//edit object property
keyboard
.
color
=
"white"
;
// console.log("keyboard=>", keyboard)
//remove object property
delete
keyboard
.
isNew
;
// console.log("AFTER DELETE=>", keyboard)
//call a method
console
.
log
(
keyboard
.
getDiscountedValue
(
50
)
)
;
var
allKeyboards
=
[
{
company
:
"Logitics"
,
type
:
"Mechanical"
,
code
:
"E324"
,
}
,
{
company
:
"abc"
,
type
:
"memrein"
,
code
:
"E3242"
,
}
,
{
company
:
"ABB"
,
type
:
"Mechanical"
,
code
:
"E124"
,
}
,
]
;
// console.log(allKeyboards[1])
// allKeyboards[1].company = 'A COMPANY'
// console.log(allKeyboards[1])
// var keyboardDiv = document.getElementById("keyboards");
// function getItem(ele) {
// console.log("ele==>", ele.id);
// // var item = allKeyboards[ele.id]
// // item.code = prompt('New Code')
// allKeyboards.splice(ele.id, 1);
// console.log("allKeyboards updated=>", allKeyboards);
// showAllData();
// }
// function showAllData() {
// keyboardDiv.innerHTML = "";
// allKeyboards.forEach(function (data, ind) {
// // console.log("Index->", ind, "data=>", data)
// var ele = `<div onclick = "getItem(this)" id=${ind}>${data.code} - ${data.company} - ${data.type} </div>`;
// keyboardDiv.innerHTML += ele;
// });
// }
// showAllData()
//constructor function
function
Student
(
name
,
fatherName
,
dob
,
rollNo
,
attendance
)
{
console
.
log
(
this
)
;
this
.
name
=
name
;
this
.
fatherName
=
fatherName
;
this
.
rollNo
=
rollNo
;
this
.
dob
=
dob
;
this
.
attendance
=
attendance
;
this
.
totalClasses
=
50
;
this
.
calculateAge
=
function
(
)
{
var
studentsDob
=
new
Date
(
this
.
dob
)
.
getFullYear
(
)
;
var
currentYear
=
new
Date
(
)
.
getFullYear
(
)
;
var
age
=
currentYear
-
studentsDob
;
return
age
;
}
;
this
.
inPunctual
=
function
(
)
{
}
;
}
var
student1
=
new
Student
(
"Ahmed"
,
"Abdullah"
,
"10-03-2000"
,
3132
,
45
)
;
var
student2
=
new
Student
(
"sad"
,
"dsa"
,
"10-03-2005"
,
3133
,
40
)
;
var
student3
=
new
Student
(
"sa"
,
"a"
,
"10-03-2001"
,
3134
,
49
)
;
var
student4
=
new
Student
(
"dssds"
,
"ds"
,
"10-03-1998"
,
3135
,
37
)
;
var
student5
=
new
Student
(
"dsasssss"
,
"dsasdsadas"
,
"10-03-2009"
,
3130
,
50
)
;
console
.
log
(
student3
)
;
// var student1 = {
// name: "Ahmed",
// fatherName: "Abdullah",
// rollNo: 3132,
// };
var
student2
=
{
name
:
"Usman"
,
fatherName
:
"Abdullah"
,
rollNo
:
3131
,
}
;
var
student3
=
{
name
:
"Ahsan"
,
fatherName
:
"Ayaz"
,
rollNo
:
3133
,
}
;
Back
|
FazBrowse Home
|
New Git URL