INTERMEDIATE JAVASCRIPT, INTERVIEW QUESTIONS.
1. Truthy and Falsy values :
Truthy values —
Falsy values —
2. Null Vs Undefined :
- Null —
Null is an assigned value. Null is an empty or non-existent value.
The null keyword is “null”.
2. Undefined —
Undefined typically means a variable has been declared but not defined yet.
The undefined keyword is “undefined”.
3. Double vs Triple equal :
Double equal (==) checks the value.
Triple equal (===) checks value and type.
4. Map, Filter, Find :
Those are 3 really powerful array functions:
map — map() when you want to transform elements in an array. The map returns an array with the same length.
filter — filter() When you want to select a single element from an array. Filter as the name implies, it returns an array with fewer items than the original array.
find — find() When you want to select a single element from an array. Filter returns the first items in an array that satisfies a condition.
5. Scope, block scope :
The scope of a variable declared with var. In JavaScript, scopes are created by code blocks, functions, modules. let and const are block scope. Block scope is within curly brackets.
6. Closure :
Closure means that an inner function always has access to the vars and parameters of its outer function, even after the outer function has returned. A closure gives you access to an outer function’s scope from an inner function.
7. Array slice :
Javascript array slice() method extracts a section of an array and returns a new array. The original remains unchanged.
- Copies elements from an array
- Returns them as a new array
- Doesn’t change the original array
8. Array splice :
The splice() method changes an array, by adding or removing elements from it.
- Used for adding/removing elements from an array
- Returns an array of removed elements
- Changes the array
9. Array join:
The join() method is used to join the elements of an array into a string.
10. Break and Continue :
Break Statement — Break statement used to “jumps out” of a loop. It breaks the loop and continues executing the code after the loop.
Continue statement — The continue statement “jumps over” one iteration in the loop and continues execution of the loop with the next iteration.