
arr.unshift
addtodo() {
console.log(this.value)
this.todos.unshift(
{
id: this.todos[this.todos.length - 1].id++,
title: this.value,
text: 'todo',
}
)
this.value = '';

arr.shift


addtodo() {
console.log(this.value)
this.todos.shift(
// {
// id: this.todos[this.todos.length - 1].id++,
// title: this.value,
// text: 'todo',
// }
)
arr.pop


arr.splice()
addtodo() {
console.log(this.value)
this.todos.splice(2, 1,
{
id: this.todos[this.todos.length - 1].id++,
title: this.value,
text: 'todo',
}
)
this.value = '';
}
}


배열 두번째 부터 객체 3개를 삭제 한다면?
addtodo() {
console.log(this.value)
this.todos.splice(2, 3,
// {
// id: this.todos[this.todos.length - 1].id++,
// title: this.value,
// text: 'todo',
// }
)
this.value = '';
}

배열 맨 앞 추가 unshift
배열 맨 뒤 추가 push
배열 중간 추가 splice
addtodo() {
console.log(this.value)
this.todos.unshift(
{
id: this.todos[this.todos.length - 1].id + 1,
title: '맨앞에 추가',
text: '배열의 앞 추가는 unshift'
}
)
this.todos.push({
id: this.todos[this.todos.length - 1].id + 1,
title: '맨뒤에 추가',
text: '배열의 맨 뒤 추가는 push'
})
this.todos.splice(1, 0,
{
id: this.todos[this.todos.length - 1].id + 1,
title: this.value,
text: 'todo',
}
)
this.value = '';
}

addtodo() {
console.log(this.value)
this.todos.shift(
)
this.todos.pop()
this.todos.splice(2, 2,
// {
// id: this.todos[this.todos.length - 1].id + 1,
// title: this.value,
// text: 'todo',
// }
)
this.value = '';
}
