Front End Job interview Tips Flashcards
What are examples of falsy values?
In JavaScript, a value is considered falsy if it coerces to false when evaluated in a boolean context. Examples are 0, empty strings, etc
How can you declare variables in Javascript?
There are three options, var, let and const.
Before VAR was used everywhere, but because of problems const and let were introduced.
Var can be both globally or locally scoped
Var variables can be re-declared and updated
Problem if you’re not awhere of reassigning var when its already globally used and the reassigned in block scope
With const you cannot re-assign values, while this is still possible with let.
What’s the difference between == and ===
=== more strict, compare value and type,
== compares only the value
What’s the difference between Undefined and Null?
The key difference between null and undefined is that undefined is often the default value for variables that haven’t been assigned any value, whereas null is a deliberate assignment to represent the intentional absence of a value.
In summary, undefined usually means “I haven’t set a value for this variable yet,” while null means “I’ve intentionally set this variable to have no value.” Both are used to handle different situations in your JavaScript code.
What’s the spread operator? and what’s the Rest operator?
Imagine you have a basket of fruits, and you want to create a new basket that contains all the fruits from the original basket plus a new one. The spread operator in JavaScript is a bit like adding fruits to your basket.
In JavaScript, the spread operator is written as three dots (...
). It’s a convenient way to take the elements from an iterable (like an array) and spread them into a new context, like another array or function arguments.
The rest operator in JavaScript is also represented by three dots (…), but its usage is a bit different from the spread operator. While the spread operator is used to spread elements, the rest operator is used to gather or collect multiple elements into a single variable.
What’s the function of Destructuring in Javascript?
Destructuring in JavaScript is a powerful feature that allows you to extract values from arrays or properties from objects and assign them to variables in a more concise and readable way. It simplifies the process of working with complex data structures
What are Promises in Javascript?
Promises in JavaScript are objects that represent the eventual completion or failure of an asynchronous operation and its resulting value. They are a way to handle asynchronous operations more effectively, providing a cleaner and more readable syntax compared to traditional callback functions.
A promise can be in one of three states:
Pending: The initial state, before the promise is fulfilled or rejected.
Fulfilled: The operation completed successfully, and the promise has a resulting value.
Rejected: The operation failed, and the promise has a reason for the failure.
Explain Pass by value vs Pass by reference
Primitive data types (like numbers, strings, and booleans) are passed by value. Meaning you’re making a copy.
Objects and array are passed by reference, you’re passing a reference to the ‘container’ holding the variable
What’s the spread operator?
In JavaScript, the spread operator is written as three dots (...
). It’s a convenient way to take the elements from an iterable (like an array) and spread them into a new context, like another array or function arguments.
What are sets?
A collection of unique values
What are template literals?
Template literals help make it simple to do string interpolation, or to include variables in a string.