Handling Forms & User Input
What input analysis pattern does this demonstrate?
let lastValue = '';
input.addEventListener('input', e => {
const newValue = e.target.value;
const hasTyped = newValue.length > lastValue.length;
const diff = hasTyped ?
newValue.slice(lastValue.length) :
lastValue.slice(newValue.length);
lastValue = newValue;
if (hasTyped) {
handleNewCharacters(diff);
} else {
handleDeletion(diff);
}
});