- JavaScript Syntax and variables
- JavaScript Operators
- JavaScript Conditional statements
- JavaScript Loops
- JavaScript Functions
- JavaScript Interactions with HTML
JavaScript Syntax and Variables
What is JavaScript Syntax?
Syntax means the rules of writing JavaScript code so that the browser can understand it(Just loke English has grammar,JavaSript has syntax)
Basic JavaScript syntax Rules
1.Statements end with semicolon ;
Forex:- alert("Hello JavaScript");
2.JavaScript is case-sensitive
let name="Ravi";
let Name="Kiran"; // both are different variables
3.Comments in JavaScript
// This is a comment
/*multi liner comment */
4.Blocks use {}
if(true){ console.log("Inside block"); }
What is a variable??
A variable is used to store data that can be used later(Variable=Container for data)
JavaScript provides 3 keywords:
How to Declare variables in JavaScript
1.var(old-avoid) for ex:- var city="Hyd" --old style avoid
2.let(recommended) for ex:- let age =25;
3.Const(Constant) for ex:- const country="India";
- JavaScript Operators
- JavaScript Conditional statements
Loop
While
For
Do while Loop
JavaScript Function
A function is a block of code that performs a task and can be reused
A .Simple function
function greet() {
alert('Hello');
}
greet();
B. Function with parameters
function add(a,b){
return a+b;
}
Console.log(add(10,5) //15
C. Arrow function(intro)
Const multiply =(a,b) => a*b;
console.log(multiply(4,5)); //20
--Thanks
No comments:
Post a Comment