Some Combinations Of JavaScript And ES6…
- Truthy and Falsy
there are some truth and falsy statement , if a variable declare a these words or these values (
0, null, undefined, "", NaN,false
) the statement will be falsy. Here is an example..
const name = 0if(name){console.log("Name is true");} else{console.log("Name is False");}expected Result //Name is False
if a variable declare a these words or these values (
"0", " ", [], {}, truth or any kind of object
) the statement will be truthy. Here is an example..
const name = "Karim"if(name){console.log("Name is true");} else{console.log("Name is False");}//Expected result : Name is True
2. Null Vs Undefined
If a statement or a variable uses these states , the answers will be Undefined or Null . Lets look at the overview.
1.
let Pakhi;
console.log(pakhi)
//expected result : undefined2.
function add (num1, num2){
console.log(num1 + num2)
}
const result = add(12, 13);
console.log(result)
//expected result : undefined
3.Double Equal or Tripple equal
If we use double equal (==) , the answer will not vary the data type , it will show any kind of output ,
If we use double equal (=+=) , the answer will vary the data type , it will show exact output .
4. Map , Filter, Find, Smart way for running loop
In ES6 , We will use Map instead of for loop .. Here is an example .
const Numbers = [23, 22,44,21,445,24]
const result = numbers.map(x => x * x)
console.log(result)
For filter method ,The output we get more data.
const bigger = numbers.filter(x => x > 5)console.log(bigger)
For find method , we get a single matched data.
5. Object Method Property
Usually , having a function in a object is defined Object method. Here is an example
const person = {
first : "Rahman",
second : "bhai",
getFullName : function(){
console.log(this.first, this.second)
6. Object Use Bind To Borrow Method From Another Object
If an object’s function used in another object function is called bind method . Here is an example
const person= {
first : "Rahman",
second : "bhai",
money :23440;
getBill : function (amount){
this.money = this .money - amount
return this.salary
}const bigperson = {
first : "jamal",
second : "Bhuia"
}
const BigChargeMoney = person.getBill.bind(bigperson)
console.log(BigChargeMoney(200))
7. title: Why We Need Accessibility? How Does It Work?
Accessibility: Accessibility in web page or referred to as a11y which can be used by everyone and more confidently used by those who are not able to read or cannot see .
There are some of guidelines for creating accessibility websites .
WCAG, WAI_ARIA
8.Asynchronus JavaScript SetTimeOut , SetInterval
If we call setTimeOut in a function , that function will execute after all function executed.
If we call setInterval in a function , that function will execute after all function executed and it will continue a moment while , if we set the exact time for looping .