Javascript Tutorial Development Tutorials, Guides & Insights
Unlock 12+ expert-curated javascript tutorial tutorials, real-world code snippets, and modern dev strategies. From fundamentals to advanced topics, boost your javascript tutorial skills on DeveloperBreeze.
Adblocker Detected
It looks like you're using an adblocker. Our website relies on ads to keep running. Please consider disabling your adblocker to support us and access the content.
Comparison and Logical Operators
Example:
let age = 20;
let hasID = true;
if (age >= 18 && hasID) {
console.log("Access granted.");
} else {
console.log("Access denied.");
}
// Output: "Access granted."
Arithmetic Operators
console.log(5 + "5"); // "55"
console.log(5 - "2"); // 3 (string "2" is coerced to number)
- Attempts to convert the operand to a number.
- Example:
Non-Primitive Data Types (Objects, Arrays, and Functions)
- Function Declaration:
function greet(name) {
return `Hello, ${name}!`;
}
console.log(greet("Alice")); // "Hello, Alice!"
Primitive Data Types
JavaScript provides several primitive data types to store basic values. These data types are immutable, meaning their values cannot be changed directly. Understanding these types is fundamental for working with data in JavaScript.
Primitive data types represent single values (as opposed to complex objects). JavaScript has the following primitive types:
Variables and Constants
{
let x = 10;
console.log(x); // 10
}
console.log(x); // Error: x is not defined
- Variables are accessible within the entire function they are declared in.
- Example: