- Words which are not denfined and not reserved for javascript language that are not understandable by compiler called words.
- The reserved set of words that are understood by the javascript compiler called Keywords. we cannot use them, it will cause an error.
- The place to store data and referred back with the name defined, they are like data containers to store data.
- in javascript we use
var let and const
keywords to declare variables. - variable declaration & assignment.
- var a; this is called declaration; a=12; this is called assignment.
var
variables areES5
andlet, const
variables are newly addedES6
features.var
variables can be added to the window object by itself; where aslet
variables will not added to the window.var
varibles are function scoped; where aslet
variables are braces{},(),[]
scoped.var
can be hoisted ; let will not hoisted.var
variables can be re-declared without any error;
- declaring a variable called declaration
var number
and assigning with=
assign operator is called assignmentnumber = 12
.
- variables declared but not assigned any value called
undefined
and varibales not delcared callednot defined.
- variables and functions are hoisted,their declarations will goes top of the code.
var
Variables declartion code will move to top.
- Primitives
- Number,String,Boolean,Null,undefined,symbol
- immutable values cannot be changed or copied
- if there are no brackets then they are primitives.
- Non-Primitives or Referrences
- arrays,object,sets
- if there are any kind of brakcet then they are called reffernces.
if else and else if
are conditionals in javascript.
-
if
is conditional check only executes when the conditon turns true; -
else if
this will re-runs the conditionals and checks conditions and returns only if it is true; -
else
this will be the default if everything turns false this will be executed.
- for loop & while loop
- loops will repeat the iterations desired number of times.
- for loops will be initiated with the initial variable and there will be a check conditional
-
there are 2 steps in functions;
-
function declaration and function calling
-
the set of code wants to re-use whenever we needed.
- in functions
parenthesis ()
a placeholder values is placed to get the value as input calledparameter
- the value which we give to modify the function called
arguments
.
- list of values called elements; can hold any type of values
- arrays are indexed from 0
- objects are set of variables and functions stored as key- value pair.