10-javascript-frameworks icon indicating copy to clipboard operation
10-javascript-frameworks copied to clipboard

Nice video! But just one minor remark...

Open dotnetCarpenter opened this issue 4 years ago • 0 comments

I enjoy the whirlwind tour of all those frameworks - five of those I didn't even know existed! I have only work with vue and react so seeing the other frameworks with a simple app was great. I was thinking it was too simple but it made it a lot easier to compare the frameworks at a glance.

My only remark is that HTML/DOM can be written more declarative than you show.

<!-- `return false` is equal to `event.preventDefault()` -->
<form onsubmit="addTodo(this.elements.todo.value); this.reset(); return false">
    <input name="todo" type="text">
    <input type="submit" value="Add Todo">
</form>
function createListElement(text) {
    const li = document.createElement('li');
    li.textContent = text; // faster and safer than .innerHTML
    return li;
}

function addTodo(todoText) {
    todoData.push(todoText);
    todoList.appendChild(createListElement(todoText));
    localStorage.setItem('todos', JSON.stringify(todoData));
}

dotnetCarpenter avatar Aug 13 '21 06:08 dotnetCarpenter