0% found this document useful (0 votes)
0 views

JS NOTES

This document serves as a beginner's guide to JavaScript, covering how to run JavaScript both online and on a local computer. It explains the concept of variables and constants, including how to declare and initialize them, as well as the differences between 'var' and 'let'. Additionally, it outlines the rules for naming variables and introduces the 'const' keyword for creating constants.

Uploaded by

jalalifaiz1156
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

JS NOTES

This document serves as a beginner's guide to JavaScript, covering how to run JavaScript both online and on a local computer. It explains the concept of variables and constants, including how to declare and initialize them, as well as the differences between 'var' and 'let'. Additionally, it outlines the rules for naming variables and introduces the 'const' keyword for creating constants.

Uploaded by

jalalifaiz1156
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Getting started with javascript :

 JavaScript is a versatile, high-level programming


language that is widely supported across all major
operating systems.

 You can run JavaScript on your computer using the


following two methods:
1. Run JavaScript Online.
2. Run JavaScript on your Computer.

 In this tutorial, you will learn both method.

Run JavaScript Online :


 You can try Programiz free online JavaScript
compiler to run JavaScript code directly in browser
without any need for installation.

Run JavaScript on Your Computer :


 If you prefer to run JavaScript locally on your
computer, this guide will walk you through the step
needed for windows, macOS, Linux.
JavaScript Variables and Constants :
1. JavaScript Variables :
 A JavaScript variable is a container for storing
data. For example,
Let num = 5;
Here, num is a variable that stores the number
5.

2. Declaring variables in JavaScript :


 In JavaScript, we use [var] or [let] keywords to
declare variables. For example,
Var age;
Let name;
Here, age and name are variables.

What is Difference between var and let :


 Both var and let are used to declare variables.
However, there are some differences between
them
var Let
Var is used in older Let is the new way of
version of JavaScript. declaring variables,
starting with ES6
(ES2015).
Variables created with Variables declared with
var are function-scoped, let are block-scoped,
meaning they can be meaning they can only
accessed anywhere be accessed within the
within the function they block where they were
were defined in. declared.
For example, var x; For example, let y;
3. Initialize Variables in JavaScript :
 We use assignment operator “=” to assign a
value to a variable.
//declare variable num
Let num;
//assign 5 to num
Num = 5;

 Here 5 is assign to the variable num.


 We can also initialize variables during the
declaration.
// declare variable num1 and assign 5 to it.
Let num1 = 5;
// declare variable num2 and assign 6 to it.
Let num2 = 6;

4. Change the value of variables :


 The value of variable may vary. Hence, the
name variable.

5. Rules for Naming JavaScript Variables :


 Variable names must start with a letter, an
underscore( _ ), the dollar sign ( $ ).
 Variables cannot start with numbers.
 Variables names are case-sensitive. So ‘age’
and ‘Age’ are different variables.
 Variable names cannot be keywords(Special
words reserved for specific purposes in
JavaScript such as ‘if’ , ‘else’ , ‘let’ , ‘var’ etc.).

JavaScript Constants :
 A constant is a type of variable whose value cannot
be changed.
 In JavaScript we used ‘const’ keyword to create
constants.

Sislovesme - Alexa Grace Fucks Her Stepbro

You might also like