Javascript anothor name is Eggmassscript
symble - es-6
bigint - es-11
new datatypes
variable diclaration
var , let , const
and without declatoin
they are two type of launage is there
1. Statically
2.Dynamically
STATIC TYPE
JAVA IS ALSO A STATIC TYPE
STRING name = abc;
name = xyz;
in java will reacin the value of the variable;
in static is must declaor the datatype
DYNMIC TYPE
JAVASCRIPT IS A DYNAMIC TYPE
student = abc;
without meansion the data types
html - is like builded house
css - is paint for the house
javascript - is a function like a electronic items
in javascript will replace the defecaties in var datatype
so using let and const
/block scope - peticular function only it's work
//global scope - program fully worked
print will use consol-log in javascript
goble scope and local scope
In javascript
//block scope - peticular function only it's work
//global scope - program fully worked
//without any keyword
//var - function scope
//let - block level scope
//const - block scope
function learnvariable() // name of the function
{
name = "vicky"; // data store
console.log(name);//printstatement
}
learnvariable();//calling menthod
in javascript if the variable will called only called and will show in the output
if the output will show will use print statement outside of the function
if the function difind and function calling is now completed
why we doesn't use the var in javascript
for example code:
function learnvariable()
{
var name = "vicky";
var name = "main";
console.log("inside",name);
}
learnvariable();
console.log("outside",name);
output
inside main // it's take a reassing in data
outside vicky//outside calling will take the without reassing data
in var problem
1.it is not a block scope
2.redeclation defecaties or reassing issue
3.var will allow two time diclare the var
so ,this proble will solve to use let
function learnvariable()
{
let name = "vicky";
console.log("inside",name);
}
learnvariable();
console.log("outside",name);
in this function will only allow one time declear the let
will scerate the progrmaimg launage
1.compiled prg
2.interpretor prg
will using const will never change or not reasing the value of variable
function learnvariable()
{
const Username = 10;
usernamr =20; // its shows a error
console.log("inside",Username);
}
learnvariable();
console.log("outside",Username);
next will find the datatype of the vale
let i = "hii";
console.log(typeof i);//if find the type of the datatype using typeof
output:
string
Top comments (0)