#46MediumQuiz
46. Why is extending built-in JavaScript objects not a good idea?
JavaScriptOOP
Mutating native prototypes (like Array.prototype) risks naming collisions, breaks for...in loops, and conflicts with future language specs.
Example 1:
safeLast([10, 20, 30]); // 30
safeLast([]); // undefinedsolution.js
Returns last item of a non-empty array
expect(safeLast([10, 20, 30])).toBe(30)