0% found this document useful (0 votes)
19 views2 pages

PIS Lect6

This document discusses JavaScript fundamentals including an overview of JavaScript, its uses, and basics like variables, scope, and data types. JavaScript is an important scripting language used to create interactive and dynamic websites and applications. It is one of the most popular programming languages worldwide.

Uploaded by

mynaa3643
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views2 pages

PIS Lect6

This document discusses JavaScript fundamentals including an overview of JavaScript, its uses, and basics like variables, scope, and data types. JavaScript is an important scripting language used to create interactive and dynamic websites and applications. It is one of the most popular programming languages worldwide.

Uploaded by

mynaa3643
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Chapter 10: JavaScript Fundamentals 144

10.1 Overview
JavaScript is a scripting language that is used to create interactive and dynamic websites.
Interactive website means, users can perform some action on website for example: Button
click, submit a form, write comments and live chat. Dynamic website means, the website that
changes its content or layout like: Sliding effect, Ecommerce website and Quiz website.
JavaScript is the most popular programming language in the world. It is used in almost all
popular websites like: Google, Facebook, Twitter, Amazon, Netflix and many others. Great
thing about JavaScript is that you will find tons of frameworks and Libraries to reduce your
time to create websites and mobile apps. Some of the popular frameworks are: React, Angular
and Vue.js. If you learn JavaScript, it opens up a lot of job opportunities in the software
development industry.
Uses of JavaScript is not only limited to front-end web development, It is also used in back-
end web development, Mobile app development, Desktop app development, Game
Development and API creation. By using JavaScript, you can easily create website like
Amazon and Netflix, Mobile apps like Instagram and WhatsApp, Games like Tic Tac Toe
and Snake Games.

10.2 Basics
Variable & scope
Variables are used to store data. They are similar to containers where we use to store things
at home. To declare a variable in JavaScript, we use the var, let, or const keyword.
var x;

Here 'var' is the keyword to declare a variable and 'x' is the identifier or name of the variable.
We can also declare a variable as:
let x;

Or
const x;

The var keyword is the oldest and most common way to declare variables. The let keyword
is a newer keyword that was introduced in ES6. The const keyword is used to declare
Chapter 10: JavaScript Fundamentals 145

constants, which are variables that cannot be changed. Once you have declared a variable,
you can assign a value to it using the equal sign (=). For example:
var x = 30;

The above code declares a variable called x and assigns it the value "30". Variables can be
used to store any type of data, including numbers, strings, objects, and arrays.
Example:
var x = "Hello World"; //string

A JavaScript name must begin with: A letter (A-Z or a-z) , A dollar sign ($) Or an underscore
(_). Subsequent characters may be letters, digits, underscores, or dollar signs. Numbers are
not allowed as the first character in names. JavaScript is case sensitive — firstName and
firstname are different.

Let keyword
The let keyword in JavaScript is used to declare a block-scoped variable. This means that
the variable is only visible within the block in which it is declared.
Example:
let x = 10;
if (x > 5)
{
let y = 20;
console.log(y); // 20
}
console.log(y); // Reference Error: y is not defined

If you try to access the variable y outside of the if statement, you will get a ReferenceError.
This is because the variable y is not defined outside of the if statement.

Const keyword
The const keyword in JavaScript is used to declare a constant variable. This means that the
variable cannot be reassigned to a new value.
Example:
const a =4;
console.log(a); // 4
a = 5 // Error: Cannot assign to constant variable

You might also like