A high-level, dynamic, untyped, and interpreted programming language.
Primarily known for making web pages interactive.
Variables: Storing information for reuse.
Declared using var
, let
, or const
.
Example: let name = 'John';
Data Types:
String: Textual data (e.g., 'Hello World'
)
Number: Numerical data (e.g., 42
)
Boolean: True or false (e.g., true
)
Object: Collection of key-value pairs (e.g., {key: 'value'}
)
Array: List-like object (e.g., [1, 2, 3]
)
Operators:
Arithmetic: +
, -
, *
, /
Assignment: =
, +=
, -=
Comparison: ==
, ===
, !=
, !==
, >
, <
Control Structures:
Conditional Statements: if
, else if
, else
Loops: for
, while
, do while
Example: for(let i = 0; i < 5; i++) { console.log(i); }
Functions:
Blocks of code designed to perform a particular task.
Declared using the function
keyword.
Example: function greet() { console.log('Hello!'); }
JavaScript can access and manipulate HTML and CSS.
Use document.getElementById()
, document.querySelector()
, etc.
JavaScript can respond to user actions, such as clicks or key presses.
Example: button.addEventListener('click', function() { alert('Button clicked!'); });
Keep code organized and easy to read.
Use descriptive variable and function names.
Comment your code for clarity.
Mozilla Developer Network (MDN)
FreeCodeCamp
Codecademy