Diff test

- Posted in Uncategorized

Iets om later nog te gebruiken. Code diffs om een concept uit te leggen:

	let count = 0;

	const button = document.createElement('button');
-	button.textContent = `Clicks: ${count}`;
+	const strong = document.createElement('strong');
+	strong.textContent = count;

+	button.append(
+		document.createTextNode('Clicks: '),
+		strong
+	);

	button.addEventListener('click', () => {
		count += 1;
-		button.textContent = `Clicks: ${count}`;
+		strong.textContent = count;
	});

	return button;
}

Via.

Leave a Reply

Your email address will not be published. Required fields are marked *