Binary Search in JavaScriptBinary search is a 'divide and conquer' algorithm that finds the position of a specified input value within a sorted array. With a Big-O runtime of O(log n), it is an efficient way to search large sorted arrays.Read More
How to use the React useCallback() hookReact LogoThe useCallback() hook is a function provided by React which can help boost performance by preventing unnecessary component re-renders. It is especially useful when you have a function that is being passed to multiple child components. However, optimizations do not come for free and useCallback() should be used carefully.Read More
What is the difference between props and state in React?React LogoProps and state in React are both JavaScript objects which hold information about what will be rendered in a React component. A change in either props or state will trigger a component to re-render, but there are significant differences in how they are used.Read More
How to filter an array in JavaScriptThe filter() method in JavaScript iterates over an array and creates a new array which contains the subset of the elements that pass the test implemented by a provided callback function.Read More
How to map over an array in JavaScriptReact LogoThe map() method in JavaScript iterates through an array, invoking a provided callback function on each element and adding the returned value of this function to a new array.Read More
How to capitalize the first letter of a string in JavaScriptTo capitalized the first letter of a string in Javascript, the .toUpperCase() method can be combined with the .slice() method. If we want to capitalize the first letter of every word in the string, the .split() method can be used first.Read More
Converting a string to a number in JavaScriptThe parseInt() function is a commonly used method for converting a string into a number in JavaScript. The global Number() constructor function is a more performant alternative, while the parseFloat() function can be used to convert an string into a floating point number.Read More
Converting a number to a string in JavaScriptThe most commonly used method of converting a number to a string in JavaScript is the toString() method, but alternatives such as the String() constructor function or the toFixed() method are also available.Read More
How to check if letter is uppercase in JavaScriptUtilizing the charCodeAt() method and Unicode, we can determine whether a letter in a string is uppercase or not.Read More
How to get the first letter of a string in JavaScriptTo get the first letter of a string in Javascript, the .charAt() method can be used. Alternatively, the first character of a string can be accessed using square bracket notation with the first index (e.g. "test string"[0])Read More