10 Question 1 solution

Rabiul Islam
3 min readMay 8, 2021
  1. Double == vs Triple === : Double equal means check only value of the object. Triple equal means check value and type both then give the result. Double equal is less important when come to compare two objects use in code cause triple equal is check all thing proper way and get the exact right result. For example:
//double ==const first= 420;
const second = '2';
if (first == second) {
console.log("Yes")}
else {console.log("No")}
//triple === const first= 420;
const second = '2';
if (first === second) {
console.log("Yes")}
else {console.log("No")}

2.Closure Method: If one function into another function. Then we use or call the second function. So that creat a close environment it’s referencing an external variable which is called closure. For example:

function remote() {
let count =0;
return function(){count++;
return count;}}
const tv1 = remote();
console.log(tv1());
const tv2 = remote();
console.log(tv2());

3.Apply vs call: If the object has a method also have to use the method we have used in threeway like: i)bind, ii) apply, and iii)call. Apply→a →array →a [] And Call →c →coma →c , . For example :

const person = { firstName:'Amir', lastName:'Khan',salary:155555,
getFullName: function (){console.log(this.firstName, this.lastName);}
chargeBill: function(amount, tips, tax) {console.log(this);
this.salary = this.salary -
amount-tips-tax;
return this.salary;}}
//Call
const firstPerson ={firstName:'Ameen',lastName:'siy',salary :25000}
person.chargeBill.call(firstPerson, 900, 45, 55);
console.log(firstPerson.salary);
//Apply
const secondPerson ={firstName:'Abir',lastName:'Khan',salary :27000}
person.chargeBill.apply(secondPerson, [900, 45, 55]);
console.log(secondPerson.salary);
console.log(person.salary);

4.This keyword: “This” is a keyword to use in the javascript calling method. “This” is the helper to find out repeat object value. If you want to use the “this” keyword you have to have a value on the left side of the “this” keyword. Who runs the function context is called “this” value and determine have to on the left side. If the left side nothing then it will be automatically windowed for more example:

function add(first, second) {consloe.log(this);
return first + second; }

5.Remove duplicate item: Remove duplicate item from an array is an important thing in javascript. Cause you have to face so many common comments or numbers in your data or array. So you have to or try to avoid those data then this method we help you to do this. For example:

var numbers =[4,5,6,4,8,7,8,5,2,1,0]
var unique =[];
for (var i=0, i< numbers.length; i++)
{ var element = numbers[i];
var index.unique.indexof(element);
if (index == -1){ unique.push(element);}
console.log(unique)

6.Reverse: Reverse a string is an important method so that you can make look different on your website by using it. For example, you are trying to propose someone then you play a trick you use a reverse string then she/ he clicks it will be normal. For example:

var love ="I love you"
var reverse ='';
for(var i=0, i< love.length; i++)
{var element = love[i];
reverse= element + reverse;}
console.log(love) //normal
console.log(reverse)

7.Fibonacci series using a loop: Fibonacci sequence is javascript method is used to find out the value of the series by a loop through. You can also say that sequence mathematic work. For example:

function fibonacci(number){var fibo = [0,1];for (var i=2; i <= number; i++){fibo[i] = fibo[i-1] + fibo[i-2];}return fibo}var result = fibonacci(10);console.log(result);

8.Creat Fibonacci Series: Create fibonacci series in a recusive way.For example:

function fibonacci(number){if (number == 0){return[0];}else if (number == 1) {return[0,1];}else{var fibo = fibonacci (number-1);var nextElement = fibo [number-1] + fibo [number-2];fibo.push(nextElement);return fibo;}}var result = fibonacci(15);console.log(result);

9.Event Bubble: Propagating an event from the lowest to the upward. You can make it by helping with Html, CSS. It will show the work by click. You can make it by following my step:

i)div#container>ul#myList>li.item*5>lorem3

ii)Upper site of <ul> write <h1>My List</h1>

iii)1st li → <li id =”first”>

iv) <script> document.getElementById(‘fisrs’).addEventListerer(‘click’, function(event){ console.log(‘first item click’;})

v)1st ‘container’ → console.log(‘container click’);

vi)1st ‘myList’ → console.log(‘UL click’);

10.Event Delegate: The benefits of event delegate are:

i)Attach events at the parent element

ii)Less event handler setup(not adding events for child elements)

iii)No need to set up the event for newly added elements.

--

--