0% found this document useful (0 votes)
9 views1 page

JavaScript Shortcuts Guide

This document provides a collection of JavaScript shortcuts and features, including console methods, variable declarations, template literals, arrow functions, and destructuring. It also covers advanced topics like spread/rest operators, optional chaining, and async/await. These notes serve as a quick reference for efficient JavaScript coding practices.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views1 page

JavaScript Shortcuts Guide

This document provides a collection of JavaScript shortcuts and features, including console methods, variable declarations, template literals, arrow functions, and destructuring. It also covers advanced topics like spread/rest operators, optional chaining, and async/await. These notes serve as a quick reference for efficient JavaScript coding practices.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

JavaScript Shortcuts - Notes

1. Console Shortcuts:
- [Link](): Prints output to the console.
- [Link](): Prints error messages.
- [Link](): Displays data in table format.
- [Link]() & [Link](): Measure execution time.
2. Variable Declaration:
- let: Block-scoped variable.
- const: Block-scoped constant.
- var: Function-scoped variable (use less often).
3. Template Literals:
Use backticks `` ` `` to insert variables directly: let name = "John";
[Link](`Hello, ${name}!`); 4. Arrow Functions:
Shorter syntax for functions: const add = (a, b) => a + b; 5. Default Parameters:
function greet(name = "Guest") { [Link]("Hello " + name); } 6. Destructuring:
Extract values from arrays/objects easily: const [a, b] = [1, 2];
const {x, y} = {x: 10, y: 20}; 7. Spread & Rest Operators:
let arr1 = [1, 2];
let arr2 = [...arr1, 3, 4]; 8. Ternary Operator:
let age = 18;
let status = age >= 18 ? "Adult" : "Minor"; 9. Short-Circuit Evaluation:
let name = userName || "Guest"; 10. Optional Chaining:
let city = user?.address?.city; 11. Nullish Coalescing Operator (??):
let value = input ?? "Default"; 12. for...of Loop:
for (let item of array) { [Link](item); } 13. Map & Filter:
let doubled = [Link](n => n*2);
let evens = [Link](n => n%2===0); 14. Object Property Shorthand:
let name = "John";
let person = { name }; 15. Async/Await:
async function fetchData() {
let data = await fetch(url);
}

You might also like