|
|
|
|
|
by uwu
3203 days ago
|
|
not a change to an existing thing but i have a feature idea: variables that aren't initialized until the first time they're accessed textarea.onkeydown = event => {
// doesn't get the properties until they're accessed
const get {selectionStart, selectionEnd, value} = textarea;
// doesn't actually call .slice yet
const get selectedText = value.slice(selectionStart, selectionEnd);
// ...
if (event.key === "Enter") {
// initializes selectedText
console.log("selected text: " + selectedText);
// uses the same value, doesn't reinitialize it
selectedText;
}
};
|
|