Tricky Things and Basic Problem Solving in JavaScript
1. We all know about a type of value that returns true or false. It is called boolean. Truthy value is a type of value that returns true.
On the other hand, falsy value returns false.
2. We are often confused about null vs undefined. Null is a type but undefined is an object.
We can declare a variable but if we do not set its value then it returns undefined. Whereas, null is the value that can be assigned to other variables.
3. “==” and “===” is another thing that makes us confused. We use “==” when we only want to compare the values. However, we use “===” when we want to compare the values and the type as well.
4. Call, bind, apply: Call is used when we want to pass arguments one by one. Apply is used when we want to pass the argument as an array. Bind returns a new function and allows you to pass the array and number of arguments.
5. Largest element in an array: There are several ways to find the largest element in an array. One of the fastest ways is:
6. Remove Duplicate item from an array:
7. Count the number of words in an array:
8. Reverse a String:
9. Factorial In Recursive Function JavaScript:
10: How to Check Prime Number Using JavaScript: