Literals

Definition: A literal is a value that is directly written in the source code. It can be a simple value like a number, string, boolean, or more complex constructs like Object Literals or Array Literals.

Examples:

5
'Test'
true
['a', 'b']
{ color: 'red', shape: 'Rectangle' }

Key Point: Literals are the fundamental units of JavaScript, representing simple or complex values directly within the code.

Identifiers

Definition: An identifier is a sequence of characters used to identify a variable, function, or object in JavaScript. It can start with a letter, the dollar sign $, or an underscore _, and may contain digits.

Examples:

5
'Test'
true
['a', 'b']
{ color: 'red', shape: 'Rectangle' }

Usage of Dollar Sign: The dollar sign is commonly used to reference DOM elements in JavaScript.

Note: Some names are reserved for JavaScript internal use and cannot be used as identifiers.

Variables

Definition: A variable is a reference to a value. It allows us to store and later access that value through a given name. JavaScript is loosely typed, allowing flexibility in variable usage.

Declaration:

// Using const (for constants)
const a = 0;

// Using let (for mutable variables)
let b = 'Hello';

// Using var (older way, less commonly used today)
var c = true;

Case Sensitivity: Identifiers in JavaScript are case-sensitive.

Key Point: Variables provide a way to store and manage values, offering flexibility through different declaration keywords (const, let, var).

Understanding these fundamental concepts sets the groundwork for further exploration into JavaScript programming. As we progress, we’ll delve into more advanced constructs and practices. Stay tuned for more insights into JavaScript development!

Được phân loại trong:

Code, Guides, Javascript,