Hello,
In PHP you would do something like this:
class Foo
{
protected $zar;
protected $bar;
public function setZar($someValue)
{
$this->$zar = $someValue;
}
public function setBar($someValue)
{
$this->$bar = $someValue;
}
public function myMethodWhereEverythingHappens()
{
if ( $this->zar == $this->bar) {
//...
}
}
}
Would it be correct to do the following in JS?
var Foo = {
zar: '',
bar: '',
setZar: function(someValue){
this.zar = someValue;
},
setBar: function(someValue){
this.bar = someValue;
},
myMethodWhereEverythingHappens: function() {
if(this.zar == this.bar) {
//do something
}
},
}
Would that be correct? What’s the js pattern for dealing with that kind of OO considerations?