Faced an interesting (for me) example:
archive(): void { var oldTodos = this.todos; console.log(this.todos); console.log(oldTodos); this.todos = []; console.log(oldTodos); console.log(this.todos); oldTodos.forEach((todo: Todo) => { if (!todo.done) this.todos.push(todo); }); } The array has a reference type, right? And, like, this.todos = []; It should just rub the array and all links will now have an empty array, but this is not the case and it does not behave like a reference type. What is the matter and where am I mistaken? All code: http://plnkr.co/edit/x0aeMXEwYo67pAWYXzfA?p=preview