Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
Tags
- Associated Value
- CoreData Concurrency
- Swift closure
- Swift 고차함수
- NSSortDescriptor
- 다익스트라 이해
- 일급 객체
- iOS Static Library
- NSPredicates
- leetcode #01
- Raw value and Associated value
- Persistent store Coordinator
- Clean swift
- LightWeight Migration
- Swift LinkedList
- expensive operation
- iOS Static Library 사용하는방법
- 트레일링 클로저
- CoreData Stack
- CoreData Filter
- Java
- 스위프트 클로저
- dateFormatter
- codability
- 1009번
- NSManagedObject SubClass
- 2022 부스트캠프
- persistentStoreCoordinator
- CoreData
- Swift
Archives
- Today
- Total
하루를살자
JS Clone Project [to-do list] - 4, Deleting to-Do list 본문
Key Points
- Logic of deleting selected item on the array
- Use of filter()
function deleteTodo(event){
//We can identify which li called this event by inspecting event.target object.
console.log(event.target);
console.dir(event.target.parentElement.innerText);
//I designate the selected li element
const li = event.target.parentElement;
//Remove the list
li.remove();
toDos = toDos.filter((item) => item.id !== parseInt(li.id));
saveToDos();
}
Things learned
- filter() returns creating new array containing element is true for the argument, in this case, "item.id !== li.id".
- Remember to save the new array into the local storage after creating new toDos array.
'JS' 카테고리의 다른 글
JS Clone Project [Weather] - 1, weather API (0) | 2021.12.09 |
---|---|
JS Clone Project [Weather] - 1, getting location (0) | 2021.12.09 |
JS Clone Project [to-do list] - 3, Saving to-do list (0) | 2021.12.09 |
JS Clone Project [to-do list] - 1,2 (0) | 2021.12.05 |
JS Clone Project [Background] (0) | 2021.12.05 |
Comments