0% found this document useful (0 votes)
3 views3 pages

JS - 1

JavaScript is a versatile programming language used for creating dynamic and interactive web applications, characterized by its interpreted nature and support for first-class functions. Key features include prototype-based inheritance, multi-paradigm support, and dynamic typing, with variables declared using let, const, or var. The document also covers JavaScript's data types, operators, and the differences between JavaScript and TypeScript, emphasizing the importance of proper variable naming and the distinction between null and undefined.

Uploaded by

narayan.6701
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)
3 views3 pages

JS - 1

JavaScript is a versatile programming language used for creating dynamic and interactive web applications, characterized by its interpreted nature and support for first-class functions. Key features include prototype-based inheritance, multi-paradigm support, and dynamic typing, with variables declared using let, const, or var. The document also covers JavaScript's data types, operators, and the differences between JavaScript and TypeScript, emphasizing the importance of proper variable naming and the distinction between null and undefined.

Uploaded by

narayan.6701
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/ 3

JavaScript - 1

22 July 2023 13:09

Introduction
— JavaScript is used to add functionality on our website or webapps. This makes the website usable. JavaScript is
a programming language that can run in web browsers and other environments. It can be used to create
dynamic and interactive web pages, as well as applications, games, and more. JavaScript is one of the most
popular and widely used languages in the world.

— It is a case sensitive language and camelCase is recommended to use in JS.

Features of JavaScript
1. It is interpreted, meaning it does not need to be compiled before running.

2. It supports first-class functions, meaning functions can be treated as values and passed as arguments or
returned from other functions.

3. It is prototype-based, meaning objects can inherit properties and methods from other objects without using
classes.

4. It is multi-paradigm, meaning it supports different programming styles such as object-oriented, imperative,


and functional.

5. It is dynamic, meaning it can change the type and structure of variables and objects at runtime.

Setting Environment for JS


— JavaScript files have .js extension and they can be created inside any IDE but we have to learn Console before
using JavaScript. We can use this console inside any browser by going to the inspect option and clicking on the
console option.

— Console uses REPL which means Read-Evaluate-Print-Loop.

1. First Console reads the code written

2. Then the code will get evaluated

3. Evaluated output will get printed on the screen

4. At last the cycle will repeat again

— We can use Ctrl + L to clear the console in Windows and for Mac it's cmd + K. We can also use up and down
arrow keys to access the previous inputs.

let, const & var Keywords


— They are some reserved keywords in JS which are used for different purposed and can't be used as variable
names. Semicolon is used to terminate the statement.

1. let: It is used to decalare the variable in JS.

let a; OR let a=25;

2. const: It is used to create constant values of any variable which can't be reassigned.

const name="narayan";

3. var: This is the old syntax of declaring variables in JS. It's use was replaced by let keyword in 2015. It's a
little bit different in comparison to JS.

JavaScript Page 1
little bit different in comparison to JS.

var age=89; OR var cgpa; OR var cgpa=9.8;

Variables in JS
— Variable is a container which is used to store data into it or we can say it is the name of a storage location. We
don't need to specify the datatype with variable initialization, because JS automatically detects the type of
variable.

a=10

b=5

age=23

name="narayan"
— Declaring variables without keywords is not recommended in JS.

Datatypes in JS
— There are 7 primitive datatypes in JS which are Number, Boolean, String, Undefined, Null, bigint (not much
used) and Symbol (not much used). We can use typeof to know the datatype of any variable.

typeof name

Numbers in JS
— All integers and floating numbers are considered as numbers in JS. There is a limit for size of numbers in JS
and if the number crosses the size limit then, JS will automatically store the nearest value instead of inputted
number which will be within the limits of JS.

NaN Global Property


— It stands for Not-a-Number. It is used to denote invalid numbers which it says as NaN. But if we check the
type of NaN then it's a number. It simply means that it's a number but it's not valid.

— Operations performed with NaN also give NaN as output.

Operator precedence in JS
— This is the general order of solving any expression in JavaScript. BPMDRAS means Bracket > Power >
Multiplication > Division > Remainder > Addition > Subtraction

( ) > ** > * > / > % > + > -

— If there are multiple power operators present in any statement then evaluation of power operators will be
done from right to left in JavaScript.

Operators in JS
— There are 5 basic types of operators in JS.

1. Arithmetic: Basic mathematical operation like ( + , - , * , / , % , ** )

2. Unary: Increment and Decrement operators ( a++, ++a, a--, --a )

3. Assignment: Used to assign values to a variable ( =, +=, -=, *=, /=, )

4. Comparison: Used to compare two values ( <, >, ==, <=, >=, != ). We can compare a number to string
with (==). It will only compare the value but not the type. Whereas ( === ) will compare both value and
type of the variables.

JavaScript Page 2
type of the variables.

5. Logical: Boolean operators like AND, OR and NOT ( &&, ||, ! )

Comparison for Non numbers


— We can also compare non number characters using comparison operators. They are being compared
according to their unicode value. Lowercase characters have greater unicode value than uppercase.

— 'a' will have lesser unicode value than 'b', 'c' have more unicode value than 'b' but less unicode value when
compared with 'd'. This cycle is valid for all uppercase and lowercase alphabets.

Identifier Rules
— All JavaScript variables must be identified with unique names (identifiers)

1. Names can contain letters, digits, underscores, and dollar signs (no space).

2. Names must begin with a letter, $ and _

3. Names are case sensitive

4. Reserved words cannot be used as names

Boolean in JS
— It is used to represent a true or false value.

let age=23;

let isAdult = true;


— We can change datatype of variables by assigning them new value. This is only valid in JavaScript not in C, C++
or Java.

What is TypeScript
— It is developed by Mircosoft and now it has been adapted by many companies. TypeScript is an extended and
strict version of JavaScript. Where JavaScript is dynamic typed language but TypeScript is static typed
language.

null and undefined in JS


— a variable that has not assigned a value is of type undefined. Whenever JavaScript does not know about some
variable or identifier it gives us a undefined output.

let a;
— Whereas the null value represents the intentional absence of any object value. It is to be explicitly assigned.

JavaScript Page 3

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy