# Javascript tips and tricks to Optimize Performance

By [Raymon Casey](https://paragraph.com/@raymon-casey) · 2023-03-31

---

**Use Array Filter** It is a small hack to filter out bucket of elements from the array pool. This method creates an array filled with all array elements that pass a test (provided as a function). According to requirement create a callback function for non-required elements.

**Using String replace function to replace all the values** The String.replace() function allows you to replace strings using String and Regex.Basically this function replaces the string at its first occurrence. But to replace all using replaceAll() function, use /g at the end of a Regex.

**Use breakpoints and Console for Debugging** With the help of breakpoints or debugging points you can set multiple barriers to rectify source of error at every barrier.

**Convert to floating number without killing performance** Often we use math.floor, math.ceil and math.round for eliminating decimals. Instead of using them use “~~” to eliminate decimals for a value.

It is also helpful in increasing performance when it comes to micro optimizations in a code.

---

*Originally published on [Raymon Casey](https://paragraph.com/@raymon-casey/javascript-tips-and-tricks-to-optimize-performance)*
