4 ms·
I agree that append() and removeLast() would be better names. But they don't exist as built-in functions in JavaScript. Therefore I need a mnemonic that makes i
by galaxyLogic 3y ago
I agree that append() and removeLast() would be better names. But they don't exist as built-in functions in JavaScript. Therefore I need a mnemonic that makes it easy for me to remember what shift() and unshift() do.
- gabrielsroka 3y agoTry Array.prototype.append = Array.prototype.push; Etc
- galaxyLogic 3y agoThat is tempting, and I've dome similar things earlier. But I don't want to do that. Why because: It is not a good practice to modify JavaScript built-in prototypes. If that was the recommended practice then someone else's code might do a similar thing, but assign some other function to it. Whoever writes it last overrides any previous definition.
- gabrielsroka 3y ago> someone else's code I don't use someone else's code. I use my code. But I may be the minority. Use a namespace, then. Array.prototype.glAppend = Array.prototype.push;