runxinzhi.com
首页
百度搜索
JavaScript面向对象之——继承【原】
本列子参照JavaScript核心技术一书略作修改,JS中继承还远不止于此,本博只略作讲解
JS-Code
//<![CDATA
//基类
function tune(title,type,test)
{
this.title = title;
this.type = type;
this.getTitle = function(){
return "Song: " + this.title +" Type:" + this.type;
}
}
//派生类
function artist_tune(title,type,artist,test)
{
this.artist = artist;
this.toString("Artist is"+artist);
tune.call(this,title,artist);//call继承需列出参数
// tune.apply(this,arguments);//apply直接使用参数列表,不包含最后一个参数,也就是说title,type,artist,test只取前三个参数
this.toString = function(){
return "Artist :"+this.artist+" "+this.getTitle();//调用继承基类的方法
}
}
// artist_tune.prototype = new tune();
var song = new artist_tune("I want to hold your hand ","rock","Beatles","test");
alert(song.toString());
//]>
相关阅读:
VLC播放器web插件接口(Part1)
视频监控/存储系统设计要点
CVR并发写入测试
Darwin Streaming Server性能测试报告
用Red5搭建支持WEB播放的实时监控视频
RTSP协议-中文定义
网格最短路径算法(Dijkstra & Fast Marching)
三维网格精简算法(Quadric Error Metrics)附源码
三维网格细分算法(Catmull-Clark subdivision & Loop subdivision)附源码
网格测地线算法(Geodesics in Heat)附源码
原文地址:https://www.cnblogs.com/myssh/p/1614819.html
最新文章
solr——centos7 安装vmware tools问题(kernel headers)
Solr——CentOS7 设置主机名及IP映射
Linux——Linux最常用命令
solr——centos7添加vmware tools实现文件复制、拖拽
solr——centos7下yum安装
Solr——vmware安装centos7,并解决无法连接网络问题
机器学习——基础模型
Solr——从mysql数据库导入数据
点到直线距离
各种熵
热门文章
统计学脑图总结
python3正则表达式总结
numpy/pandas时间互相转换
[转]理解 Bias 与 Variance 之间的权衡----------bias variance tradeoff
[转]k8s核心概念
centos下etcd集群安装
用VLC读取摄像头产生RTSP流,DSS侦听并转发(二)
VLC-DSS搭建直播系统中链路断开影响测试
DSS分发压力实验
VLC播放器web插件接口(Part2)
Copyright © 2020-2023
润新知