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

推荐订阅源

腾讯CDC
The Cloudflare Blog
IT之家
IT之家
V
V2EX
雷峰网
雷峰网
MyScale Blog
MyScale Blog
P
Proofpoint News Feed
Stack Overflow Blog
Stack Overflow Blog
博客园 - Franky
Engineering at Meta
Engineering at Meta
S
SegmentFault 最新的问题
GbyAI
GbyAI
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - 司徒正美
云风的 BLOG
云风的 BLOG
小众软件
小众软件
博客园 - 叶小钗
Blog — PlanetScale
Blog — PlanetScale
C
Check Point Blog
A
About on SuperTechFans
B
Blog
月光博客
月光博客
宝玉的分享
宝玉的分享
Last Week in AI
Last Week in AI

博客园 - 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());