Course Content
Introduction to JavaScript
JavaScript is one of the most popular and widely used programming languages in the world. It plays a crucial role in web development, enabling dynamic content, interactivity, and enhanced user experiences in web pages and applications. Let’s dive into what JavaScript is, its history, and how it fits into the modern web.
0/6
How to Add JavaScript?
Before diving into the basics of JavaScript, it’s essential to understand how to include JavaScript in an HTML file. There are three main ways to do this:
0/3
Different Ways to Output Data
JavaScript provides several ways to "display" or output data, allowing you to present dynamic content to users in various ways. Each method serves a different purpose and is used in different scenarios depending on the requirements. Here are the primary methods for displaying data using JavaScript:
0/4
Variables and Constants
Variables and constants in JavaScript are used to store data values. Depending on how you declare them, their value can be changed or fixed.
0/2
Data Types
JavaScript provides different types of values that can be stored in variables. These are categorized into two types: Primitives and Non-Primitives.
0/2
Conditional Statements (if, else if, else)
Conditional statements execute different actions based on different conditions.
0/2
Arrays
In JavaScript, an array is a special type of object that stores an ordered collection of values (elements). Arrays are zero-indexed, meaning the first element is accessed with index 0.
0/5
DOM Manipulation
DOM Manipulation is the process of using JavaScript to interact with and modify the HTML and CSS of a webpage. The DOM is essentially the structure of the webpage, represented as nodes, which can be elements, attributes, or pieces of text.
0/4
String Functions in JavaScript
0/1
Number Functions in Javascript
0/1
RegEx (Regular Expressions) in JavaScript
Regular expressions (regex) are patterns used to match sequences of characters in strings. They are powerful tools for searching, validating, and manipulating text.
0/3
JavaScript
About Lesson

JavaScript has a number of methods for performing operations on numbers. Here are some common methods:

Parses a string and returns an integer or floating-point number.

JavaScript
let intNumber = "42";
console.log(parseInt(intNumber)); // Output: 42

let floatNumber = "3.14";
console.log(parseFloat(floatNumber)); // Output: 3.14

Formats a number to a specified number of decimal places.

JavaScript
let num = 3.14159;
console.log(num.toFixed(2)); // Output: "3.14"

Converts a number to a string.

JavaScript
let num = 42;
console.log(num.toString()); // Output: "42"

Rounds a number to the nearest integer.

JavaScript
console.log(Math.round(4.7)); // Output: 5
console.log(Math.round(4.3)); // Output: 4

Rounds a number up or down to the nearest integer.

JavaScript
console.log(Math.ceil(4.3));  // Output: 5
console.log(Math.floor(4.7)); // Output: 4

Returns the smallest or largest number in a list of arguments.

JavaScript
console.log(Math.min(10, 20, 30)); // Output: 10
console.log(Math.max(10, 20, 30)); // Output: 30

Generates a random number between 0 (inclusive) and 1 (exclusive).

JavaScript
console.log(Math.random()); // Output: A random decimal, e.g., 0.345678

Returns the absolute value of a number.

JavaScript
let num = -42;
console.log(Math.abs(num)); // Output: 42

Calculates power and square root.

JavaScript
console.log(Math.pow(2, 3)); // Output: 8 (2^3)
console.log(Math.sqrt(16));  // Output: 4

Checks if a value is an integer.

JavaScript
console.log(Number.isInteger(42)); // Output: true
console.log(Number.isInteger(3.14)); // Output: false