10 replies
1 recast
20 reactions
We're gonna start with variables. Mind you. I'm gonna give you the definitions in a clear, short and concise way.
Cause we gonna learn this in 5 mins .. hehe
πΉ Variables
β‘ Use let and const for block-scoped variables
β‘ Use var (function-scoped; avoid in modern code)
β‘ const is used for constants (cannot be reassigned)
β‘ Variable names must start with a letter, _, or $
πΉ Data Types
β‘ Primitive Types: string, number, boolean, null, undefined, symbol, bigint
β‘ Reference Types: object, array, function
β‘ Use typeof to check type
πΉ Operators
β‘ Arithmetic: +, -, *, /, %, **
β‘ Assignment: =, +=, -=, *=, /=, etc.
β‘ Comparison: ==, ===, !=, !==, >, <, >=, <=
β‘ Logical: &&, ||, !
β‘ Ternary: condition ? true : false
β‘ Nullish Coalescing: ??
πΉ Control Flow
β‘ if, else if, else for conditionals
β‘ switch for multiple conditions
β‘ for, while, do...while for loops
β‘ break exits a loop, continue skips an iteration 0 reply
0 recast
0 reaction
0 reply
0 recast
0 reaction
πΉ Objects
β‘ Objects store key-value pairs
β‘ Declare using { key: value }
β‘ Access with dot . or bracket [] notation
β‘ Use Object.keys(), Object.values(), Object.entries()
β‘ Use delete to remove a property
πΉ Strings
β‘ Strings can use single or double quotes
β‘ Template literals use backticks `, and ${} for variables
β‘ Common Methods:
ββ‘ length, toUpperCase(), toLowerCase()
ββ‘ includes(), indexOf(), slice(), substring()
ββ‘ replace(), split(), trim() 0 reply
0 recast
0 reaction
πΉ Math & Numbers
β‘ Use Math object:
ββ‘ Math.round(), Math.floor(), Math.ceil()
ββ‘ Math.random(), Math.max(), Math.min()
β‘ Use parseInt(), parseFloat() to convert strings
β‘ Use Number() to convert any type to number
πΉ Date and Time
β‘ Use new Date() to create date objects
β‘ Methods:
ββ‘ getFullYear(), getMonth(), getDate()
ββ‘ getHours(), getMinutes(), getSeconds()
β‘ Use set...() to change date/time values
πΉ Events
β‘ Events are actions like click, hover, etc.
β‘ Use addEventListener() to handle events
β‘ Common Events: click, submit, input, keydown, load
β‘ The event object contains details about the event 0 reply
0 recast
0 reaction
0 reply
0 recast
0 reaction
0 reply
0 recast
0 reaction
0 reply
0 recast
0 reaction
0 reply
0 recast
0 reaction
0 reply
0 recast
0 reaction
1 reply
0 recast
0 reaction
1 reply
0 recast
0 reaction