Variables are named storage locations that hold data. They allow you to make your code more readable and reusable.
Example: int age = 30; This declares an integer variable named 'age' and assigns it the value 30.
Data types define the kind of value a variable can hold. They dictate the operations that can be performed on the variable.
Common data types include:Number (integers, decimals),String (text),Boolean (true/false),Null (represents no value),Character (single characters),Array (a collection of items),Object (can hold any data)
Example: int x = 10; This is an integer variable. y = "Hello"; is a string variable. isTrue = true is a boolean variable.
Operators perform operations on data. Some common operators include:+ (addition),- (subtraction),* (multiplication),/ (division),% (modulo),== (equal to),!= (not equal to),& (bitwise AND),| (bitwise OR),^ (bitwise XOR).
Example: x = 5 + y; This is an arithmetic operation. z = x * 2; This is a multiplication operation.
null represents a missing or undefined value. Nullable types allow a variable to hold a value that might be missing.
Example: string name = null; This declares a string variable that can be `null`.
Arrays are collections of items of the same data type. They are used to store a sequence of values.
Example: int[] numbers = {1, 2, 3}; This creates an array of integers.
Objects are collections of data and methods. They provide a way to create reusable code.
Example: Person person = new Person("John"); This creates a new object named 'person' with a name property.
JavaScript uses symbols and variables for data storage. Variables are declared with `let` or `var` to be mutable.
let message = "Hello, JavaScript!"; This is a variable declaration in JavaScript.
This is a simple footer. It’s a place to return to the main content.