Js is a client-side scripting language that execute on your broweser.
Js essentially used to make your pages alive
Using Js we can capture event, create animations, validating user inputs and much more.
In present Js not only execute on browser but also on the server.
Node.js is one of the most amazing example of server-side JavaScript
History of JavaScipt
Js was developed by Brendan Eich in Netscape Communications Corporation in 1995
JavaScript started his life with the name Mocha ans was concisely named LiveScript.
In 1995 LiveScript officially renamed to JavaScript with Netscape Navigator Road leads
What is ECMAScript
ECMA stands for Europian Computer Manufacturers Association, a private international nonprofit standard organization.
In 1996 Netscape submitted JavaScript to ECMA.
JavaScript is implementation of ECMAScript.
What is ES6
ECMAScript 6 is update of ES5 which was standardize in 2009.
ES6 was published by ECMA International in June 2015.
Literals, Variables & Constants
Variables
Variable is a name that contains a specific value
Constant
In ES6 a new Keyword added in the JavaScript which is const.
Constant also hold value but unlike variables it can't be changed after initialization.
Identifier
Variables and constants are usually call identifier.
Identifier consists of letters numbers Underscore(_) and the Dollar ($) sign.
Unicode Characters are allowed
Identifier must start with the letter Dollar sign ($) or underscore(_).
Identifier cannot be a reserved word.(words that created for a specific task).
Literals
You are providing a value directly in the program.
Literals is just the way to create identifier with the value.
Primitive Type & Object
Primitive Types
JavaScript Data or values are primitive or object. Primitive data are immutable means we cannot change the value of the variable after initializing JS recognized four types of numerical literals, Binary, Decimal, Octal, HexaDecimal.
Boolean
Boolean is just a value type that have only two possible values. True or False. We dont use boolean values inside quotaion marks.("")
Symbols
In ecmascript 6 we have a new type symbol. Symbols is the new data type in es6 which represent Unique tokens. Once you created a symbol it is unique and it will not match any other symbols.
Null & Undefined
JS has two special types null and undefined. Null has only one possible value which is Null and undefined has only one possible value undefined Both Null and undefined Represent something doesn't exist.
Object Types
Array
Date
Regular Expression
Map & WeakMap
Set and WeakSet
What is Object?
Objects are mutable
Can change any value anytime.
Object is just like a Container that can have different kind of data.
Object literal syntax :{}
Array
Array is Collection of Different types of Data.
Array Start with [0] and end with [n] value.
Array element can be any type of of data, It may be objects or primitive type.
Array size is not fixed so you can add and remove array element anytime.
Array is zero based. So the first element of the array is 0 next element is 1 and so on.
Date
Represent date and time using date object.
Date
Represent date and time using date object.
Regular Expression
It is a sub language of JavaScript
Used to perform Complex search and replace operations on strings.
Maps and Sets
In new ECMAScript 6 a new data type introduced is map and set and their week counterpart, WeekMap and Weakset.
Maps are just likean object but it offers more advantages than object in certain situations
Set are similar to array expect they can't content duplicate element.
String
A Collection of characters, Numbers, and Symbols.
In Js string represents UNICODE TEXT
Unicode text is a computing industrial standard for representing text data.
Unicode store letter and characters By assigning a number of each one.
Special Chracters
Escaping Characters
Description
\n
New line
\r
Carriage Return
\t
Tab
\' & \"
Single & Double Quote
\`
Backtick (new ES6)
\$
Dollar Sign (new ES6)
\\
Backslash
\\uXXXX
Unicode Format
If & Else
Switch
Loop
While Loop
Do while Loop
for Loop
Nested for Loop
for/in Loop
for/of Loop
Expressions
Expression is a statement that evaluate to a value
Primary Expression/ Simple Expression
Constant or literal values, it can be variable reference or certain language result keywords
5.30- number literals
"Name" - String literals
JavaScript Reserve Words
Null
True
False
Bare Expressions
str - expression evaluate to the value of the str
undefined - it is a global variable , not a keyword like null
False
Operators
Assignment Operators
Arithmetic Operators
Comparison Operators
String Operators
Logical Operators
Bitwise Operators
Ternary Operators
Type Operators
Operator
Description
typeof
Returns the type of a variable
instanceof
Returns true if an object is an instance of an object type
Destructing Assignment Operator
It is new in EcmaScript 6
Object and Array Operators
instanceof Operator
Delete Operator
Conditional Operators
Jump Statements
jump statement are used to jump the execution to the new location
Labeled Statements
allow us to specify name to the specific block that can refer it to somewhere in the program
Continue Statements
Restart the loop after next iteration
Return Statements
Functions
Declare with function keyword followed by function name