Zepto
10+ Swiss Pac Interview Questions and Answers
Q1. What is denbouncer and throttle
Debouncer and throttle are techniques used to limit the frequency of function calls.
Debouncing delays the execution of a function until a certain amount of time has passed without the function being called again.
Throttling limits the frequency of function calls to a certain rate, executing the function at fixed intervals.
Debouncing is useful for events that may be triggered multiple times in quick succession, such as resizing a window.
Throttling is useful for events that need...read more
Q2. Major difference between class based components and class based components
There is no difference between class based components and class based components.
There seems to be a typo in the question.
Assuming the question is about functional components vs class components, the major difference is that class components use a class to define the component while functional components are defined as functions.
Class components have access to lifecycle methods while functional components do not.
Functional components are simpler and easier to read and write.
E...read more
Q3. What is the problem with colosures
Closures can cause memory leaks if not handled properly.
Closures can hold references to variables outside of their scope, preventing them from being garbage collected.
If closures are used excessively or not released properly, they can cause memory leaks.
To avoid memory leaks, make sure to release closures when they are no longer needed.
Q4. How to do deep copy ?
Deep copy creates a new object with the same values as the original object.
Use Object.assign() method to create a deep copy of an object.
For nested objects, use recursion to copy all levels.
For arrays, use slice() method to create a new array with the same values.
Avoid using spread operator for deep copy as it only creates a shallow copy.
Q5. What is promise.all()
promise.all() is a method that takes an array of promises and returns a new promise that resolves when all promises in the array have resolved.
It is used to handle multiple asynchronous operations simultaneously.
If any of the promises in the array rejects, the returned promise will be rejected with the reason of the first rejected promise.
The resolved values of the promises are returned as an array in the same order as the input promises.
Q6. What is closure in javascript
Closure is a function that has access to its parent scope even after the parent function has returned.
Closure allows for private variables and functions in JavaScript.
It is created when a function returns another function.
The inner function has access to the outer function's variables and parameters.
Example: function outer() { let x = 10; return function inner() { console.log(x); } }
The inner function can access and modify the value of x even after outer() has returned.
Q7. What is curry function
Currying is a technique of transforming a function that takes multiple arguments into a sequence of functions that each take a single argument.
Currying allows partial application of a function
It helps in creating reusable functions
Curried functions are easier to compose and chain
Example: const add = (a) => (b) => a + b; add(2)(3) returns 5
Q8. What is memoization?
Memoization is a technique of caching the results of a function to improve performance.
Memoization is used to avoid redundant calculations by storing the results of a function and returning the cached result when the same inputs occur again.
It is commonly used in recursive functions and functions with expensive computations.
Memoization can be implemented manually or by using libraries like Lodash or Memoizee.
Example: Memoizing a Fibonacci function can significantly improve it...read more
Q9. Implement curry function
Curry function is a higher-order function that allows partial application of arguments.
Currying transforms a function that takes multiple arguments into a series of functions that take one argument each.
It returns a new function until all the arguments are received and then executes the original function.
Example: const add = (a, b) => a + b; const curriedAdd = curry(add); curriedAdd(2)(3) returns 5.
Q10. Shallow copy vs deep copy
Shallow copy only copies the reference to an object while deep copy creates a new object with a new memory address.
Shallow copy is faster and uses less memory than deep copy.
In shallow copy, changes made to the original object will reflect in the copied object as well.
Deep copy creates a completely new object with its own memory space.
In JavaScript, arrays and objects are assigned by reference, so a shallow copy will only copy the reference to the original object.
In Python, y...read more
Top Front end Developer Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month