Сообщение от unclechu
|
как работать с приватными переменными из функции в прототипе
|
Сообщение от nasqad
|
надо новое замыкание создавать
|
может так
var human = (function () {
var prototype = {}
prototype.getName
+function(){
var name;
prototype.getName = function (str) {
if (str) name = str
return name
}
function constructor(data) {
name
}
}()
constructor.prototype = prototype
return constructor
}())
var h1 = new human
h1.getName('Vasia')
var h2 = new human
h2.getName('Petia')