JavaScript Fundamentals: Quick Reference Cheat Sheet
Classified in Computers
Written on in English with a size of 2.61 KB
JavaScript Fundamentals Cheat Sheet
1. Variables
let
: Used to declare variables that are block-scoped. This means they only exist within the block they are defined in (e.g., inside a loop or an if statement).const
: Used for constants, which are also block-scoped. Once assigned a value, they cannot be reassigned.var
: Declares variables that are function-scoped. This can lead to issues with variable hoisting and is generally less preferred in modern JavaScript.
2. Functions
- Functions are reusable blocks of code designed to perform a specific task. They can take parameters (inputs) and can return values.
- Functions can be defined in different ways, including traditional function declarations and arrow functions, which provide a more concise syntax.