List of variables
Variables name | Description |
---|---|
oldest keywords to declare a variable and var can be updated and redeclared. | |
block-scoped, can’t be accessible out the particular block, and let can be updated but not redeclared | |
block scope, neither be updated nor redeclared. |
Syntax:
var geek = "Hello Geek" // Declaration using var
let $ = "Welcome" // Declaration using let
const _example = "Gfg" // Declaration using const
Example: Here is the basic example of using var, let, and const variables.
var a = "Hello Geeks"
var b = 10;
console.log(a);
console.log(b);
// Using let
{
let num = 20;
// Calling the function inside block
console.log(num)
}
// Calling the function outside
// block throws a Error
console.log(num)
// Using const
const x = 22;
{
const x = 90;
console.log(x);
{
const x = 45;
console.log(x);
}
}
console.log(x);
Output:
10
Hello Geeks
20
Uncaught ReferenceError: num is not defined
90
45
22
JavaScript Basics
JavaScript is a versatile, lightweight scripting language widely used in web development. It can be utilized for both client-side and server-side development, making it essential for modern web applications. Known as the scripting language for web pages, JavaScript supports variables, data types, operators, conditional statements, loops, functions, arrays, and objects. With JavaScript, you can create dynamic, interactive, and engaging websites.
These are the basics that you need to learn before deep dive into JavaScript:
Table of Content
- Variables in JavaScript
- Data type in JavaScript
- Conditional statements in javascript
- Function in Javascript
- Looping in javascript
- Comments in javascript
- Operators in javascript
Contact Us