吴裕雄--天生自然 JAVASCRIPT开发学习:prototype(原型对象)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>菜鸟教程(runoob.com)</title>
</head>
<body> <h2>JavaScript 对象</h2> <p id="demo"></p> <script>
function Person(first, last, age, eye) {
this.firstName = first;
this.lastName = last;
this.age = age;
this.eyeColor = eye;
} var myFather = new Person("John", "Doe", 50, "blue");
var myMother = new Person("Sally", "Rally", 48, "green"); document.getElementById("demo").innerHTML =
"我的父亲年龄是 " + myFather.age + "。我的母亲年龄是 " + myMother.age;
</script> </body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>菜鸟教程(runoob.com)</title>
</head>
<body> <h2>JavaScript 对象</h2> <p>你无法给构造函数添加新的属性。</p> <p id="demo"></p> <script>
function Person(first, last, age, eye) {
this.firstName = first;
this.lastName = last;
this.age = age;
this.eyeColor = eye;
} Person.nationality = "English"; var myFather = new Person("John", "Doe", 50, "blue");
var myMother = new Person("Sally", "Rally", 48, "green"); document.getElementById("demo").innerHTML =
"我父亲的国籍是 " + myFather.nationality;
</script> </body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>菜鸟教程(runoob.com)</title>
</head>
<body> <h2>JavaScript 对象</h2> <p id="demo"></p> <script>
function Person(first, last, age, eye) {
this.firstName = first;
this.lastName = last;
this.age = age;
this.eyeColor = eye;
this.nationality = "English";
} var myFather = new Person("John", "Doe", 50, "blue");
var myMother = new Person("Sally", "Rally", 48, "green"); document.getElementById("demo").innerHTML =
"我父亲的国籍是 " + myFather.nationality + "。我母亲的国籍是 " + myMother.nationality;
</script> </body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>菜鸟教程(runoob.com)</title>
</head>
<body> <h2>JavaScript 对象</h2> <p id="demo"></p> <script>
function Person(first, last, age, eye) {
this.firstName = first;
this.lastName = last;
this.age = age;
this.eyeColor = eye;
} Person.prototype.nationality = "English"; var myFather = new Person("John", "Doe", 50, "blue");
document.getElementById("demo").innerHTML =
"我父亲对国籍是 " + myFather.nationality;
</script> </body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>菜鸟教程(runoob.com)</title>
</head>
<body> <h2>JavaScript 对象</h2> <p id="demo"></p> <script>
function Person(first, last, age, eye) {
this.firstName = first;
this.lastName = last;
this.age = age;
this.eyeColor = eye;
} Person.prototype.name = function() {
return this.firstName + " " + this.lastName
}; var myFather = new Person("John", "Doe", 50, "blue");
document.getElementById("demo").innerHTML =
"我对父亲是 " + myFather.name();
</script> </body>
</html>
吴裕雄--天生自然 JAVASCRIPT开发学习:prototype(原型对象)的更多相关文章
- 吴裕雄--天生自然 JAVASCRIPT开发学习:RegExp 对象
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...
- 吴裕雄--天生自然 JAVASCRIPT开发学习:Number 对象
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...
- 吴裕雄--天生自然 JAVASCRIPT开发学习:对象 实例(2)
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...
- 吴裕雄--天生自然 JAVASCRIPT开发学习:条件语句
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...
- 吴裕雄--天生自然 JAVASCRIPT开发学习:对象
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...
- 吴裕雄--天生自然 JAVASCRIPT开发学习
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...
- 吴裕雄--天生自然 JAVASCRIPT开发学习:函数定义
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...
- 吴裕雄--天生自然 JAVASCRIPT开发学习: this 关键字
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...
- 吴裕雄--天生自然 JAVASCRIPT开发学习: 表单
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script> ...
随机推荐
- 京东首页如何实现pc端和移动端加载不同的html的?
进入www.jd.com后代码判断是手机的话就跳转m.jd.com let ua = window.navigator.userAgent.toLocaleLowerCase() let murl = ...
- Day 27:Xpath技术
xPath技术 问题:当使用dom4j查询比较深的层次结构的节点(标签,属性,文本),比较麻烦!!! xPath作用 主要是用于快速获取所需的节点对象. 在dom4j中如何使用xPath技术 1.导入 ...
- OI生涯回顾
OI回忆录只是一个预告,估计等2020高考结束才放出来吧. 先写一下自己简单的OI历程吧: 小升初刚起步 初一 第一次比赛,NOIP PJ组215分,踩线1=,全省rk86,全国rk677(毕竟AH ...
- docker 后台运行和进入后台运行的容器
先创建并进入一个新的被命名为newos的新容器 docker run -it --name newos docker.io/centos #创建并指定端口号映射 docker run -d -p ...
- python 首先生成包含1000个随机字符的字符串,然后统计每个字符的出现次数
题目:首先生成包含1000个随机字符的字符串,然后统计每个字符的出现次数 import string import random x = string.ascii_letters + string.d ...
- Django——HttpResponse()
HttpResponse(content, #返回给视图函数的内容 content_type=None,#返回给视图函数的类型 text/html文本.text/plain.css.js.xml.js ...
- vue使用Vant UI中的swiper组件及传值
子组件SwiperBanner <!-- --> <template> <div class="swiper"> <van-swipe : ...
- 第二周的java
- python---函数作用域
1.作用域 local:局部作用域 E(Enclosing):闭包函数外的函数中 G(global): 全局作用域 B(Build-in):內建作用域 查找变量的顺序,从上到下 2.函数内的变 ...
- 每天一点点之vue框架开发 - 部署到线上
1.在项目根目录下运行如下命令 npm run build 会生成一个dist目录, 2.然后将dist目录上传至服务器就可以访问页面了,不需要配置vue环境了.