Prefer spread: Math.max(...arr) instead of Math.max.apply(null, arr). Spread is more readable and modern. Use apply only in old codebases without spread support.
Should you use apply or spread in modern JavaScript?
More FAQs in call, apply, and bind Best Practices
Prefer arrow functions for callbacks: setTimeout(() => obj.method(), 1000) instead of setTimeout(obj.method.bind(obj), 1000). Arrows are more readable. Use bind for permanent binding in class constructors.
For method borrowing: Array.prototype.slice.call(arguments). This is still the standard way to convert array-like objects to arrays, although Array.from(arguments) is a modern alternative.
In the constructor: this.method = this.method.bind(this). Or use arrow class fields: method = () => { ... }. Both ensure this is always the instance, even when the method is detached.
Still have questions?
Browse all our FAQs or reach out to our support team
Want to upskill yourself?
Your learning library
Small steps. Big possibilities.
Find your next course. Build something great.