Aula 9 - Modificadores de acesso

OOP Javascript - ES5

function Person(_name, _age, _height) { var name = _name; var age = _age; var height = _height; this.initialize = function () { console.log('Init function'); }; function privateFunc() { console.log('Private function'); } this.teste = function () { privateFunc(); }; this.sayHello = function (name) { console.log('Hello ' + name); }; this.hello = function hello(name) { console.log('Hello ' + name); }; this.getName = function getName() { return name; }; this.setName = function setName(_name) { name = _name; }; this.getAge = function () { return age; }; this.setAge = function (_age) { age = _age; }; this.getHeight = function getHeight() { return height; }; this.setHeight = function setHeight(_height) { height = _height; }; } Person.static_method = function () { console.log('This is my first static method'); }; Person.static_method(); Person.static_attr = 'My first static attribute'; console.log(Person.static_attr); var jean = new Person('Jean', 48, 1.76); console.log(jean); jean.sayHello(jean.getName()); jean.teste();