Variable Declaration
In JavaScript declaring variables is different from other Programming Languages, for example:
i = 10;
i = 20;
console.log(i);
but this allows duplicate variables.
var i =10;
i = 20;
console.log(i);
this also allows duplicate variables.
let i = 10;
let i = 20;
console.log(i);
this is the method we use for variable declaration. because it doesn't allows duplicates.
const i = 10;
this is used for constant value and doesn't changeable.
<script> - inside this tag we write JavaScript. and it will only run
in console and not on webpage/UI.
console.log( ) is used for printing Statements.
Operators
+
10 + 5
o/p - 15
"leo" + 2
o/p - leo2
if we add (+) string to any values it also acts as string.
-
10 - 2
o/p - 8
10 - "2"
o/p - 8
the above is the example for type casting, here the string converts into int and - .
*
10 * 2
o/p - 20
"5" * 5
o/p - 25
here is the another example for type casting.
/
10 / 2
o/p - 5
10 / "2"
o/p - 5
It takes Quotient as answer.
%
10 % 3
o/p - 1
it takes remainder as answer.
Top comments (0)