JavaScript Shortcuts
Boost your productivity with these essential JavaScript shortcuts.
Shortcut | Description |
---|---|
console.log | Log output to the console |
document.querySelector | Select an element from the DOM |
document.getElementById | Get an element by its ID |
addEventListener | Attach an event handler |
setTimeout | Execute a function after a delay |
setInterval | Execute a function repeatedly with a delay |
JSON.stringify | Convert an object to JSON string |
JSON.parse | Parse a JSON string into an object |
Array.map | Apply a function to each array element |
Array.filter | Filter array elements |
Array.reduce | Reduce an array to a single value |
Array.forEach | Execute a function for each array element |
Math.random | Generate a random number |
Math.floor | Round a number down |
localStorage.setItem | Save data to local storage |
localStorage.getItem | Retrieve data from local storage |
Promise.then | Handle a resolved promise |
Promise.catch | Handle a rejected promise |
async/await | Work with asynchronous code in a cleaner way |
fetch | Make HTTP requests |