| 
		
			Сообщение от demoniqus
			
		
	 | 
	| 
		ты в корне неверно понимаешь код.
	 | 
	
Именно, иначе этого вопроса бы не было.
Я привык к такому
class Obj
{
	public $title;
	public $elements;
	
	public function __construct()
	{
		$this->title = "Object";
		$this->elements = [new Element(1, "Elements 1"), new Element(2, "Elements 2")];
	}
}
class Element
{
	public $id;
	public $title;
	
	public function __construct($id, $title)
	{
		$this->id = $id;
		$this->title = $title;
	}
}
function processElement(&$item) {
	$item = new Element(999, "New Element");
}
$o = new Obj();
processElement($o->elements[1]);
var_dump($o);
В итоге получаю то, что ожидаю:
object(Obj)#1 (2) {
  ["title"]=>
  string(6) "Object"
  ["elements"]=>
  array(2) {
    [0]=>
    object(Element)#2 (2) {
      ["id"]=>
      int(1)
      ["title"]=>
      string(10) "Elements 1"
    }
    [1]=>
    object(Element)#4 (2) {
      ["id"]=>
      int(999)
      ["title"]=>
      string(11) "New Element"
    }
  }
}
Именно поэтому я пытаюсь найти аналогичную возможность в яваскрипте.
За совет спасибо. Я такой подход рассматривал. Он мне не подходит. В реальном приложении объект довольно сложный, многовложенный.