js 定义bean

function Person() {
    this.name;
    this.setName = function(name) {
        this.name = name;
    };
    this.getName = function() {
        return this.name;
    };
}

//创建一个Person对象
var p = new Person();
p.setName("Bruce");
alert(p.getName());

你可能感兴趣的:(JavaScript,java)