Skip to content
Navigation Menu
Sign in
Products
Platform
GitHub
Repository hosting, code review, and collaboration
Copilot
AI coding agent for tasks, projects, and automated work
Build & Ship
Actions
CI/CD and automation
Code Quality
Quality analysis, fixes, and enforcement
Codespaces
Cloud development environments
Secure
Code Security
Vulnerability detection and remediation
Secret Protection
Secret scanning and leak prevention
All Features
Developers
Learn
Documentation
Training
Certifications
Build
Build with Copilot
Customize Copilot
Integrations
Explore
Trending repos
GitHub Sponsors
Developer articles
Changelog
Changelog
Your source for the latest features, improvements, and fixes across GitHub products, all in one place.
Businesses
By Stage
Enterprises
Team
Startups
Nonprofits
By Industry
Healthcare
Financial services
Manufacturing
Government
See all industries
Evaluate GitHub
Why GitHub
Customer Stories
Business insights
Trust Center
Add-ons
GitHub Advanced Security
Enterprise-grade code security
Copilot for business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Resources
Learn & Connect
Documentation
Resource center
Blog
Events & webinars
Community Forum
Customer Stories
Integrations
Support
Customer support
Training
GitHub Status
Company
About
Partners
Changelog
GitHub Universe
GitHub Universe
The event for developers, by developers — talks, workshops, and what’s next for GitHub.
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
cshuig
javascript_study
Repository navigation
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
More
items
Files
Expand file tree
master
Breadcrumbs
javascript_study
/
2.3.1_(prototype)基于原型的创建对象_model.html
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
59 lines (54 loc) · 1.77 KB
master
Breadcrumbs
javascript_study
/
2.3.1_(prototype)基于原型的创建对象_model.html
Copy path
Top
File metadata and controls
Code
Blame
59 lines (54 loc) · 1.77 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
<!DOCTYPE html PULBIC "-//W3C//DTD HTML 4.01/EN"
"http/www.w3.org/TR/html4/strict.dtd"
>
<
html
xmlns
="
http://www.w3.org/1999/xhmtl
"
lang
="
en
"
>
<
head
>
<
meta
http
=
equiv
="Content-Type" content="text/html; charset=utr-8"
/>
<
title
>
1.6.1_函数的属性length
</
title
>
<
meta
name
="
author
"
content
="
cshuig
"
/>
<
style
type
="
text/css
"
>
*
{
margin
:
0
px
;
padding
:
0
px
;
}
#
fuck_prototype
{
width
:
1000
px
;
height
:
100
%
;
position
:
absolute
;
left
:
50
%
;
margin-left
:
-500
px
;
margin-top
:
10
px
;
padding
:
10
px
;
}
</
style
>
<
script
type
="
text/javascript
"
>
/*以下样式了通过原型的创建方式:
使用基于原型的创建可以将属性和方法设置为对象的专有,
不能使用window调用*/
//第一中状态:原型
function
Person
(
)
{
}
/*第二种状态:通过Person.prototype.xxx为原型设置值,这些属性和方法都是设置在Person的原型中的*/
Person
.
prototype
.
name
=
"cshuig"
;
Person
.
prototype
.
age
=
"123"
;
Person
.
prototype
.
say
=
function
(
)
{
alert
(
this
.
name
+
","
+
this
.
age
)
;
}
/*第三中状态:创建了一个对象之后,
会在对象中有一个属性:_prop_ 这个属性是不能被访问的
当使用对象调用的时候,首先会在对象的内部找是否有这个属性,
如果没有会通过_prop_去原型中找属性,
所以当调用p1.say(),在自己的空间中不存在这个方法,就会去原型中寻找,
*/
var
p1
=
new
Person
(
)
;
p1
.
say
(
)
;
//window.say();//undefang
//以下方法可以检测出p1是否有_prop_指向Person的原型
alert
(
Person
.
prototype
.
isPrototypeOf
(
p1
)
)
;
</
script
>
</
head
>
<
body
>
<
div
id
="
fuck_prototype
"
>
<
div
>
<
img
src
="
image/原型理解1.jpg
"
>
</
div
>
</
div
>
</
body
>
</
html
>
You can’t perform that action at this time.