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>
运行代码
查看全文
相关阅读:
用户登录就显示一部分按钮,未登录就显示登录按钮
网页防止xss攻击
前端页面使用编辑器
Django框架
参数*args与**kwargs
Django的orm需要注意的地方
查看Linux服务器配置命令
PHP 浅析spl_autoload_register
ubuntu服务器上安装PHP扩展bcmath遇到的问题Sub-process /usr/bin/dpkg returned an error code (1)
JavaScript 变量and函数提升机制
原文地址:https://www.cnblogs.com/jikey/p/1728014.html
最新文章
查找表_leetcode149
查找表_leetcode49
查找表_leetcode18
查找表_leetcode15
查找表_leetcode16
查找表_leetcode1
Python中三大特性简述
redis参考地址
Django全文搜索功能
Django中分页器的使用
热门文章
Django中使用fastDFS
登录装饰器的使用
Linux安装及配置
django中使用邮箱注册激活用户配置
ajax发送请求
Django中的模型管理器models.Manager
varchar和Django中的CharField字段长度为什么不能超过255
虚拟中安装mysql
虚拟机无法联网问题解决
Django中的抽象模型类
Copyright © 2011-2022 走看看