FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
JavaScript_Study/lesson08/multipleCustomObject.html at master · hannabeasiam/JavaScript_Study · GitHub
hannabeasiam
/
JavaScript_Study
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
JavaScript_Study
/
lesson08
/
multipleCustomObject.html
Copy path
More file actions
More file actions
Latest commit
History
History
History
41 lines (41 loc) · 1.75 KB
Breadcrumbs
JavaScript_Study
/
lesson08
/
multipleCustomObject.html
Copy path
File metadata and controls
41 lines (41 loc) · 1.75 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
<!doctype html
>
<
html
>
<
head
>
<
meta
charset
="
utf-8
"
>
<
title
>
House Custom Object
</
title
>
<
script
type
="
text/javascript
"
src
="
house.js
"
>
</
script
>
</
head
>
<
body
>
<
h2
>
CIW JavaScript Specialist
</
h2
>
<
h3
>
House Custom Object
</
h3
>
<
script
type
="
text/javascript
"
>
/*using new object constructor and JSON to create custom object is not efficient when multiple instantiation of object need to
be created. Here, instantiate an object and store it in a variable myhouse, new keyword say find function call House and extend
object */
var
myHouse
=
new
House
(
5
,
'colonial'
,
1990
,
true
)
;
document
.
write
(
'My house has '
+
myHouse
.
rooms
+
' rooms.<br/>'
)
;
document
.
write
(
'My house style is '
+
myHouse
.
style
+
'.<br/>'
)
;
document
.
write
(
'My house was built in '
+
myHouse
.
yearBuilt
+
'.<br/>'
)
;
document
.
write
(
'My house has a garage: '
+
myHouse
.
hasGarage
+
'.<br/>'
)
;
document
.
write
(
'My house livingSpace is '
+
myHouse
.
livingSpace
(
30
,
70
,
2
)
+
' square feet.<br/>'
)
;
// passing length, width, numFloors as argument
myHouse
.
maintain
(
)
;
//we can use same House object to referencing instaciate another objact yourHouse
var
yourHouse
=
new
House
(
4
,
'spanish'
,
2003
,
false
)
;
document
.
write
(
'<hr>Your house has '
+
yourHouse
.
rooms
+
' rooms.<br/>'
)
;
document
.
write
(
'Your house style is '
+
yourHouse
.
style
+
'.<br/>'
)
;
document
.
write
(
'Your house was built in '
+
yourHouse
.
yearBuilt
+
'.<br/>'
)
;
document
.
write
(
'Your house has a garage: '
+
yourHouse
.
hasGarage
+
'.<br/>'
)
;
document
.
write
(
'Your house livingSpace is '
+
yourHouse
.
livingSpace
(
40
,
50
,
1
)
+
' square feet.<br/>'
)
;
</
script
>
</
body
>
</
html
>
Back
|
FazBrowse Home
|
New Git URL