i
PepsiCo
Proud winner of ABECA 2024 - AmbitionBox Employee Choice Awards
Filter interviews by
I applied via Referral and was interviewed in Mar 2024. There was 1 interview round.
const, let, and var are used to declare variables in JavaScript, but they have different scopes and behaviors.
const: used for variables that should not be reassigned, but the value can still be mutated (e.g. object properties)
let: used for variables that can be reassigned within their scope
var: function-scoped variable declaration, can be reassigned and hoisted
Hoisting is a JavaScript mechanism where variable and function declarations are moved to the top of their containing scope during compilation.
Variable declarations are hoisted but not their initializations.
Function declarations are fully hoisted, meaning they can be called before they are declared.
Hoisting can lead to unexpected behavior if not understood properly.
Closures in JavaScript are functions that have access to variables from their outer scope even after the outer function has finished executing.
Closures allow functions to access variables from their parent function even after the parent function has returned.
They help in creating private variables and data encapsulation.
Closures are commonly used in event handlers, callbacks, and in creating modules.
Example: function o...
To check for duplicate strings in an array, use a Set data structure. To remove duplicates, convert the array to a Set and then back to an array.
Create a Set from the array to automatically remove duplicates
Check if the size of the Set is equal to the size of the original array to determine if there are duplicates
Convert the Set back to an array to get the array without duplicates
Primitives in JavaScript are data types that are not objects and do not have methods.
Primitives include strings, numbers, booleans, null, and undefined.
They are immutable and passed by value.
Examples: 'hello', 42, true, null, undefined.
Top trending discussions
based on 1 interview
Interview experience
Associate Manager
617
salaries
| ₹8.1 L/yr - ₹25 L/yr |
Deputy Manager
515
salaries
| ₹5.5 L/yr - ₹16.5 L/yr |
Assistant Manager
468
salaries
| ₹4.1 L/yr - ₹15.5 L/yr |
Senior Manager
291
salaries
| ₹17.5 L/yr - ₹47 L/yr |
Manager
281
salaries
| ₹10.5 L/yr - ₹33 L/yr |
Nestle
Coca-Cola Company
Hindustan Unilever
Britannia