In PHP we do it like this:
function($param)
{
$this->{$param};
}
How can we do it in JavaScript?
I don't know PHP but you could use square bracket notation to access properties.
function(param)
{
this[param];
}
in javascript you can write like this
function House(rooms,price,garage) {
this.rooms=rooms;
this.price=price;
this.garage=garage;
}