JavaScript
JavaScript is a high-level, interpreted programming language primarily used to make web pages
interactive. It is dynamically typed language. It is both scripting and programming language
We can change the data type of the variable. we don’t pre define the data type it is decided in the runtime
Here abstraction is very high and far away from the hardware complexity more readable by the humans
Compiled Language
The source code is first converted into an intermediate binary file by a compiler. This binary file is then
executed by the machine. The entire code is checked and converted before running. If there's an error, it
won't run at all until fixed.
Examples: C, C++, Java
Interpreted Language
There is no intermediate file created. The code is read and executed line by line, [Link] there's an
error on line 10, lines 1–9 will still execute. The program stops only when it hits the error.
Examples: JavaScript, Python.
Javascript is founded by Brandon Eich
This was submitted to the ECMA (European Computer Manufacturers Association)-1996 1 st version was
release in 1997
Node js is a JS runtime environment which will allow us to run the code outside the browser.
NPM – is node package manager it is binded with node js it will be installed with the nodejs npm will
provide thelibrares required to run the JS code.
CharacterSet -
A character set is a set of valid characters that can be used to write instructions in a programming
language.
Characters Individual letters, digits or symbols. Ex a, b, 1, 2, +, =, {, }
Tokens The smallest meaningful unit formed by combining characters. Ex var, let, const, if, else,
function, =>, (), {}
Instructions (Statements) A complete meaningful action formed by combining tokens
let age = 25; [Link]("Hello");
Program A collection of instructions that performs a task
let name = "John";
let age = 25;
[Link](name + " is " + age + " years old");
Collections of characters is tokens and collection of tokens is instructions. Collections of instructions is
programs
TYPES OF TOKENS
1) Keyword – predefined words used to perform particular task. there are around 50 keywords these
are reserve words
2) Identifiers –the name given to the container or that memory location is identifier
Ex a=”ert”; here a is the identifier
Rules
Keywords cannot be identifiers
Can use letters numbers $ and _ for identifiers numbers cannot be used as first character and only
numbers cannot be used
Identifiers are case sensitive
3) Separators – are used to separate the tokens (, ; )
4) Operators – used to perform operations
Comparison operator
== , ===,!=,=>,<=,>,<
== is used to compare two values it will only compare the values Type Coercion will happen
== is called: Equality Operator or Loose Equality Operator will return false
=== is called: Strict Equality Operator or Identity Operator if fails returns false
Assignment operator =,+=,-=,*=,%=
All in One Table
Operator Example Same As Result (a=10)
= a = 10 a = 10 10
+= a += 5 a = a + 5 15
-= a -= 3 a = a - 3 7
*= a *= 2 a = a * 2 20
/= a /= 2 a = a / 2 5
%= a %= 3 a = a % 3 1
**= a **= 2 a = a ** 2 100
Datatypes
Primitive- once created it cannot be changed it is immutable
String, Numbers, Boolean, Undefined, Null
Non-Primitive
Object, Array, Functions they can be changed and they are mutable
Primitive can be changed into non primitive type as well
3 types of datatypes
let
var
const if we are using const then we have to compulsorily declare the variable in the same line