惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

月光博客
月光博客
C
Check Point Blog
J
Java Code Geeks
腾讯CDC
Apple Machine Learning Research
Apple Machine Learning Research
宝玉的分享
宝玉的分享
Microsoft Azure Blog
Microsoft Azure Blog
WordPress大学
WordPress大学
量子位
Google DeepMind News
Google DeepMind News
I
InfoQ
The GitHub Blog
The GitHub Blog
aimingoo的专栏
aimingoo的专栏
N
Netflix TechBlog - Medium
Hugging Face - Blog
Hugging Face - Blog
博客园 - Franky
V
V2EX
Blog — PlanetScale
Blog — PlanetScale
T
The Blog of Author Tim Ferriss
小众软件
小众软件
博客园_首页
人人都是产品经理
人人都是产品经理
博客园 - 聂微东
IT之家
IT之家

博客园 - HenryZhang

用javascript按需加载.js和.css文件 考虑了全半角的SubString window.open 打开的窗口关闭后 javascript小技巧 看完越狱20件必须懂的东西(转) vs2005 安装sp1 NHibernate1.2在VS2005下的配置 AJAX第十一天 AJAX第十天 AJAX第九天 AJAX第七天 AJAX第八天 AJAX第六天 JavaScript常用正则表达式 JS正则表达式问题终于解决 Ajax第五天 Ajax第四天 上传文件时用到的显示文件大小 除去所有在html元素中标记
Javascript 使用类
HenryZhang · 2007-03-13 · via 博客园 - HenryZhang

----------------------------方法一----------------------------------
//定义类
function StudentObject(){
    //Property
    this.Name = "";
    this.Age = "";
    this.Sex = "";
    this.Grade = "";
    this.Address = "";
    this.Phone = "";

    //Method
    this.tt = ff;
}
//类的方法实现
function ff(){return "my name is " + this.Name;}

//测试
var stobj = new StudentObject();
stobj.Name = "Henry";
alert(stobj.tt());

//写法2
----------------------------方法二----------------------------------
//定义类
function StudentObject() {
    //Property
    this.Name = "";
    this.Age = "";
    this.Sex = "";
    this.Grade = "";
    this.Address = "";
    this.Phone = "";
}
//Mothod
StudentObject.prototype = {
    tt: function() {return "my name is " + this.Name + " in tt";},
    bb: function() {return "my name is " + this.Name + " in bb";}
}
//测试
var stobj = new StudentObject();
stobj.Name = "dsafdsafdsa";
alert(stobj.tt());
alert(stobj.bb());