function curryFunction(a) {
  return function (b) {
    const res = a + b
    return function (c) {
      return res + c
    }
  }
}
console.log(curryFunction(1)(2)(3))

To check if an object is null or not: _.isEmpty(obj) ? true : false; - optimized approach

Array.prototype.last = function() {
    return this.length == 0 ? -1 : this[this.length - 1];
};

/**
 * const arr = [1, 2, 3];
 * arr.last(); // 3
 */

  1. Array.prototype.last:

What is Lexical Environment?

A lexical environment is the internal structure that JavaScript creates at runtime to keep track of:

It's created whenever a function is invoked or a block is entered.

Example:

js
CopyEdit
function outer() {
  let x = 10;

  function inner() {
    console.log(x); // ❓ How does this work?
  }

  return inner;
}

const fn = outer(); // outer is done, but...
fn(); // still logs 10

Here’s what’s happening:


memory management

JavaScript automatically allocates and deallocates memory using Garbage Collection (GC) mechanisms.

https://www.geeksforgeeks.org/memory-management-in-javascript/

functional prog

Functional programming is a declarative programming paradigm that treats computation as the evaluation of mathematical functions and avoids changing state and mutable data. In JavaScript, it emphasizes the use of pure functions, immutability, and higher-order functions. [[1](https://medium.com/@rashmipatil24/functional-programming-in-javascript-bfc7f53b77a1#:~:text=Functional programming (FP) is a programming paradigm,its simplicity%2C maintainability%2C and ease of testing.)]