Ten important things in javascript which is need for all.
This article most helpful for you. Let’s go…
Javascript syntax:
The syntax of javascript is the sot of rules that define a structured javascript programm.
Example:
var m , n, o; //Declare variables ;
m=6; n=7; //Assign values
o =m + n //compute values
“The javascript has two values”
- Fixed value (literal)
- Variable value (variable)
Variables:
Variable means anything that can vary and you can put a value declared a variable. Variable declared with the “var” keyword. you also declared with let and const which is version of ES6.
Example
var a = 4;
let a = 4;
const a = 4;
all are correct;
Operators:
Operator is a special symbol which is used for assignment , comparison, logical, Bitwise. Assignmet operators assign values( =, -, *, /, ==, !=, &&, ||) etc.
Example
x=7; //assign the value 7 to x;
x != y
CONDITION:
Javascript condition are multiple different types of conditons which are used to perform different actions based on different conditions. In javascript programm we can follow three conditional statements.
- if
- else if
- else.
Example
If( apple ){
eat
}else if (orange){
don’t eat
}else {
throw it in the dustbin
}
LOOP
Loop are used in Javascript to perform return tasks based on a condition. Conditions typically return true or false when analysed. Javascript used basically three type of loop;
- for…..loop,
- do…loop,
- while….loop.
Example
for(var i = 0; i <8 ; i++){
var num = num + i;
}
FUNCTION
Function is a group of reuseable code which can be called anywhere in your programm. Functions are object. Javascript function are defined with the “function” keyword.
Example
function myNumbe(a, b){
//code to be executed
return a*b;
}
ARRAY:
Javascript array means where you store multiple values in a single variable. And access the elements of an array by index number. In generally the first element of an array is index 0;
Example
var phones = [‘samsung’ , ‘iphone’, ‘oop’ , ‘redme’];
var phone = phones[0];
console.log(phone); // samsung
OBJECT:
Object is the most important in Javascript programm. If you understand object . You understand Javascript . Object has two properties ( one call key and another call value) pairs and separared by “ : ” colon. Object like variable but object can store many values.
Example
var friend = {
friendName: ‘sarra’,
age: 25,
job: ‘facebooking’,
school: ‘porirdese’
}
DATA TYPES CONCEPT :
A value in javascript is always of a certain type . Data types are used to know , this value is which type of data. Six Data types are primitive.
- Number
- String
- Boolean
- Undefined
- BigInt
- Symbol
How can you find this ?
Example
var akash = ‘upore’
console.log(type of(akash)) // string
COMPARISONS :
Javascript comparisons normally compare in two values by conditional or loigcal.
Example
if(num< 10)? ‘small num’ : ‘big number’;
if(num =10 || num =15)? ‘ok’ : ‘change it’