JavaScript programming language checks some things like that

Afroza Akter Ruma
2 min readMay 8, 2021

--

Truthy and falsy values

  • Any number 6, -6 will be taken as JavaScript true. And 0 will be false
  • Any String true, MT string false
  • The value of anything undefined is actually false

Some examples of False:

// false

// 0

// “”

// Undefined

// null

// NaN

examples of True

// All string

null Vs undefined

If you do not return a function, it will be undefined

// let pakhi

// function add (num1, num2){

// consol.log(num1+num2);

// return

// }

Even if you don’t pass any parameters, it will be undefined

// function add (num1, num2){

// consol.log(num1,num2)

// }

Property excess will be undefined

null means empty

  • If there was any thing but not later then null is used there

Double equal:

  • double equal will not check which typer. Will only check the value
  • const first

Triple equal:

  • triple equal will strate check
  • triple equal value and type will check

Closure, encapsulation, private variable:

  • If you call or return from one function to another, it will create a close environment and they leave the external variable, This is closure

The difference between Call and Apply:

  • If there is a method in an object, if you want to call it on another object, then you can apply the call
  • Apply the same thing, just apply the method to another object that you want to use in the first argument will give this and the parameters will be sent in the array

How to JavaScript works event loop stack and queue?

There is an event loop inside JavaScript. He maintains a queue and has a stack of his work. Stack wise. He puts the work from top to bottom. This is how JavaScript works.

Find the largest element of an array:

var marks = [45, 81, 63, 98, 56, 35, 23]
var marks = marks [0];
for (bar i = 0; i <marks.length; i ++)
var element = marks [i];
if (element> max)
max = element;
}
}
console.log (“Highest value is:” max);
Output: Highest value is: 98

Remove duplicate item from an array:
First we need to declare an array. If the same item is repeated in this array, we need to declare another array to remove them: which will be an empty array and we will add one item to this array and see if we add this name first. If I do, It will not add and ignore.

var name = [3, 6, 2, 7, 3, 2, 8, 1, 9, 11, 56]
var uniqueName = []
for (var i = 0; i <name.length; i ++)
var element = name [i];
var index = uniqueName.indexOf (element);
if (index == -1)
uniqueName.push (element);
}
}
Output: [3, 6, 2, 7, 8, 1, 9, 11, 56]

--

--

No responses yet