ING Bank Client Interview Questions

1. Write a function to Filter, Sort and display final products with only relevant fields

const products = [
{id:1, name: "Laptop", category: "electronics", price: 1000},
{id:2, name: "Shirt", category: "fashion", price: 1000},
{id:3, name: "Phone", category: "electronics", price: 1000},
{id:4, name: "Shoes", category: "fashion", price: 1000},
{id:5, name: "Headphones", category: "electronics", price: 1000},
]

Requirements: 

i. Filter products by category (e.g., "electronics").
ii. Sort the filtered products by price in ascending order.
iii. Make a new array with the final products to display only relevant details like "name" and "price".

-------------------------------------------------------------------------------------------------------------------------

2. Write a function to check whether an array contains any duplicate values. Return true if duplicates exist, otherwise return false.

Input: [1, 2, 3, 4, 5]
Output: false

Input: [1, 2, 3, 2]
Output: true

Requirements:

i. Avoid using nested loops(O(n²))
ii. Discuss Time & Space Complexity.
iii. Solve without using extra space (if possible)

--------------------------------------------------------------------------------------------------------------------------

3. Pass a payload to given REST API.

API: "/api/testing/v1"
Payload: {name: test, price: 3}

---------------------------------------------------------------------------------------------------------------------------
4. What is Garbage Collection

Ans: Garbage Collection (GC) is the process of automatically freeing up memory that is no longer in use to avoid memory leaks and keep the application efficient.

 Key Concepts

1. Memory Allocation

When you create variables, objects, arrays, etc., JavaScript allocates memory for them.

let user = { name: "Alice" }; // memory is allocated

2. Reachability

Garbage collectors use the concept of "reachability" to decide if an object is still needed.

Reachable = still usable = not garbage

  • Variables in scope

  • Objects referenced by reachable objects

  • Function parameters and closures

3. Unreachable Objects

If there’s no way to reach an object, it's considered "garbage" and will be collected.


let user = { name: "Alice" }; user = null; // the original object is now unreachable

๐Ÿง  Algorithms (behind the scenes)

✅ Most Common: Mark-and-Sweep

  1. Mark all reachable objects starting from roots (like global variables).

  2. Sweep through memory and delete anything not marked.


⚠️ Important Notes

  • GC is automatic, but not predictable (you can’t force it).

  • Memory leaks can still happen (e.g., if you keep references unintentionally).


๐Ÿ” Example

function demo() { let obj = { name: "Garbage?" }; // allocated // once the function ends, `obj` becomes unreachable } demo(); // `obj` is collected by GC
---------------------------------------------------------------------------------------------------------------------------
5. let vs var vs const. explain 
---------------------------------------------------------------------------------------------------------------------------
6. Explain the significance of "this" key in JavaScript.
---------------------------------------------------------------------------------------------------------------------------
7. Virtual DOM vs Shadow DOM vs Original DOM

๐ŸŒณ 1. Original DOM (Real DOM)

The actual document structure loaded in the browser.

  • ๐Ÿ“ What: The real HTML document (document, document.body, etc.)

  • ๐Ÿข Slow to update — changes cause reflows and repaints

  • ๐Ÿ” Directly manipulated via JS (getElementById, innerHTML, etc.)

๐Ÿชž 2. Virtual DOM

A lightweight in-memory copy of the Real DOM used by libraries like React.

  • ๐Ÿ“ What: JavaScript representation of the DOM

  • ⚡ Fast updates — diffs new vs old virtual DOM, applies only real changes

  • ๐Ÿง  Improves performance by minimizing real DOM manipulation

๐Ÿงฑ 3. Shadow DOM

A browser feature for encapsulating part of the DOM inside a component.

  • ๐Ÿ“ What: A scoped DOM subtree hidden from the main DOM

  • ๐Ÿงผ Isolated styles & markup — no CSS bleeding in or out

  • ๐Ÿ”’ Great for Web Components


FeatureReal DOMVirtual DOMShadow DOM
Part of browser✅ Yes❌ No (JS Concept)✅ Yes
Speed๐Ÿข Slower⚡ Faster๐Ÿš€ Fast (isolated)
Isolation❌ No❌ No✅ Yes
Used byAll web pagesReact, VueWeb Components
UpdatesManual/DirectDiff & PatchScoped and safe
---------------------------------------------------------------------------------------------------------------------------

Comments

Popular posts from this blog

insightsoftware vue js

Apexon React.js Interview

TCS vue js