Master JavaScript Programming From Scratch

Clear, interactive, and structured JavaScript lessons designed for absolute beginners.

JavaScript Basics

Learn the basic building blocks of JavaScript, including variables, values, data types, and simple JavaScript statements.

What are JavaScript Basics?

JavaScript basics are the fundamental concepts you need before building larger JavaScript programs.

In this module, you will learn how to store data, identify data types, convert values, and work with basic input and output.

JavaScript variables and data types

JavaScript variables and common data types.

Main Concepts

Variables

Variables are used to store values that your program needs to work with.

Data Types

Data types describe the kind of value stored in a JavaScript variable.

Type Conversion

Type conversion changes a value from one data type to another.

Input and Output

JavaScript can receive information and display results using different methods.

How a Variable Works

Variable and Value
Variable
→
Value
→
Data Type

Example 1: Variables

You can create variables using the let and const keywords.

let studentName = "Samadhan";
let course = "JavaScript";
const institute = "CIIT Training Institute";

console.log("Welcome to " + institute + " ❤️🧑‍🎓.....!");
console.log("Student:", studentName);
console.log("Course:", course);

Output

Welcome to CIIT Training Institute ❤️🧑‍🎓.....!
Student: Samadhan
Course: JavaScript

Basic Data Types

JavaScript values can represent different kinds of information, such as text, numbers, and true or false values.

String

Used for text values such as names and course titles.

Number

Used for numeric values such as marks, prices, and quantities.

Boolean

Represents either true or false.

Example 2: Data Types

const institute = "CIIT Training Institute";
const students = 150;
const isLearning = true;

console.log("Institute:", institute);
console.log("Students:", students);
console.log("Learning JavaScript:", isLearning);

console.log("Type of institute:", typeof institute);
console.log("Type of students:", typeof students);
console.log("Type of isLearning:", typeof isLearning);

Output

Institute: CIIT Training Institute
Students: 150
Learning JavaScript: true
Type of institute: string
Type of students: number
Type of isLearning: boolean

Type Conversion

Sometimes a value needs to be converted from one type to another. JavaScript provides methods such as Number() and String() for explicit conversion.

Example

A text value such as "100" can be converted into the number 100.

Input and Output

JavaScript can display information using console.log(). Browser-based applications can also collect user input through HTML forms and browser APIs.

const name = "CIIT Student";

console.log("Hello " + name);
console.log("Welcome to CIIT Training Institute ❤️🧑‍🎓.....!");

Output

Hello CIIT Student
Welcome to CIIT Training Institute ❤️🧑‍🎓.....!

What You Will Learn Next

JavaScript Basics Learning Flow
Variables
→
Data Types
→
Type Conversion
→
Input / Output

Summary

JavaScript basics include variables, data types, type conversion, and input and output concepts. These fundamentals provide the foundation for writing larger JavaScript programs.