zoukankan
html css js c++ java
Js对象继承
1.对象冒充
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Document</title> </head> <body> <script type="text/javascript"> function Person(personName){ this.name = personName; this.sayName = function(){ alert('my name is ' + this.name); } } function Man(name, age){ //Person.call(this, name); Person.apply(this,new Array(name)); this.age = age; this.sayAge = function(){ alert('my age is ' + this.age); } } var m = new Man('jikey', 'tom', 29); m.sayName(); m.sayAge(); </script> </body> </html>
运行代码
2.混合方式
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Document</title> <style> </style> <script> function Person(name){ this.name = name; } Person.prototype.sayName = function(){ alert('My name is ' + this.name);} function Man(name, age){ Person.call(this, name); this.age = age; } Man.prototype = new Person(); Man.prototype.sayAge = function(){ alert('My age is ' + this.age);} var tom = new Man('tom', 29); var jikey = new Man('jikey', 29); tom.sayAge(); tom.sayName(); jikey.sayName(); </script></head> <body> </body> </html>
运行代码
查看全文
相关阅读:
QTreeWidgetItem清空子节点
qt no doubments matching "ui..h" could be found
Qt 调试信息、打印信息、输出到文本
QLayout及其子类 清除添加的widget
同一个电脑安装两个jdk版本
hive javaapi 002
ActiveMQ之spring集成消息转换器MessageConverter
install Maven
install apache-activemq
MySQL 5.7.9版本sql_mode=only_full_group_by问题
原文地址:https://www.cnblogs.com/jikey/p/1728014.html
最新文章
python 调试模式pdb(转)
flask使用ajax上传图片或者文件
js调用高德地图的搜索api
js清空子元素,创建新的子元素
python nose测试框架全面介绍九---各种html报告插件对比
jenkins之另辟蹊径实现根据svn项目实现智能选择
jenkins之-----------在必要的时候并发构建
python nose测试框架全面介绍八---接口测试中非法参数的断言
python nose测试框架全面介绍七--日志相关
python nose测试框架全面介绍六--框架函数别名
热门文章
python nose测试框架全面介绍五--attr介绍
s3cmd在配置后使用时提示ERROR: S3 error: 403 (InvalidAccessKeyId): The AWS Access Key Id you provided does not exist in our records.
python pytest测试框架介绍四----pytest-html插件html带错误截图及失败重测机制
python pytest测试框架介绍三
QListWidget QListView QListWidgetItem样式设置
Qt所有滚动条的样式
QMap::remove操作,并不会调用值的析构,跟QTreeWidget同类,需要主动去释放
QFile 打开文件,不用先判断文件名是否为空,做这多余的工作
QList去掉重复项 .toSet()报错???
QAxBase: Error calling IDispatch member LineStyle: Unknown error
Copyright © 2011-2022 走看看