var Foo = function() { var name = 'zhus'; this.getName = function() { return name; } this.setName = function (name2){ name = name2; } } var foo = new Foo(); foo.setName('hah'); console.log(foo.getName()); var foo2=new Foo(); console.log(foo2.getName()); console.dir(foo); console.dir(foo2);