FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
javascript/prototype/prototype-objectbased.js at main · shangan23/javascript · GitHub
shangan23
/
javascript
Public
Notifications
You must be signed in to change notification settings
Fork
4
Star
4
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
/
prototype
/
prototype-objectbased.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
40 lines (34 loc) · 809 Bytes
Breadcrumbs
javascript
/
prototype
/
prototype-objectbased.js
Copy path
File metadata and controls
40 lines (34 loc) · 809 Bytes
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
function
object
(
o
)
{
function
F
(
)
{
}
F
.
prototype
=
o
;
return
new
F
(
)
;
}
function
objectUber
(
o
)
{
var
n
;
function
F
(
)
{
}
F
.
prototype
=
o
;
n
=
new
F
(
)
;
//uber
n
.
uber
=
o
;
return
n
;
}
var
shape
=
{
name
:
"Shape"
,
toString
:
function
(
)
{
return
this
.
name
;
}
}
var
twoDee
=
objectUber
(
shape
)
;
// user objectUber() to get parent method
twoDee
.
name
=
"2D Shape"
;
twoDee
.
toString
=
function
(
)
{
return
this
.
uber
?
this
.
uber
.
toString
(
)
+
","
+
this
.
name
:
this
.
name
;
}
var
triangle
=
objectUber
(
twoDee
)
;
// user objectUber() to get parent method
triangle
.
name
=
"Triangle"
;
triangle
.
side
=
5
;
triangle
.
height
=
10
;
triangle
.
getArea
=
function
(
)
{
return
this
.
side
*
this
.
height
/
2
;
}
console
.
log
(
triangle
.
toString
(
)
)
;
console
.
log
(
triangle
.
getArea
(
)
)
;
Back
|
FazBrowse Home
|
New Git URL