日期:2014-05-16 浏览次数:20447 次
<script type="text/javascript">
function Man(){ }
Man.prototype.getNickName=function()
{
return '爱在Cookies';
}
var man = new Man();
alert(man.getNickName());
</script>
<script type="text/javascript">
function Man()
{
// 私有静态属性
var sex='男';
//私有静态方法
function checkSex()
{
return (sex=='男');
}
//私有方法
this._getSex=function()
{
if(checkSex())
{
return '男';
}else
{
return '女';
}
}
//私有方法
this.getFirstName=function()
{
return '陈';
}
//私有方法
this.getLastName=function()
{
return '顶强';
}
}
//公共方法
Man.prototype.getNickName=function()
{
return '爱在Cookies';
}
//公共方法
Man.prototype.getFullName=function()
{
return this.getFirstName+this.getLastName;
}
//公共方法
Man.prototype.getSex=function()
{
return this._getSex();
}
//公共静态方法
Man.say=function()
{
return 'Happy new Year!';
}
</script>
public interface Person
{
string GetName();
void SetName(string name);
}
public class Man : Person
{
private string _name;
public string GetName()
{
return _name;
}
public void SetName(string name)
{
_name = name;
}
}
<script type="text/javascript">
function Man()
{
this.name = "";
Interface.registerImplements(this, Person);
}
Man.prototype.getName = function() {
return this.name;
};
Man.prototype.setName = function(name) {
this.name = name;
};
</script>
<script type="text/javascript">
function Interface(name,methods)
{
if(arguments.length!=2)
{
throw new Error("接口构造函数含" + arguments.length + "个参数, 但需要2个参数.");