General Questions Flashcards

1
Q

What is strict mode and what kind of error it will give?

A

Strict mode allows developers to apply more conditions so that the code is written in more organized and optimal way.

Some examples:
* Disallows global variable declaration ( without var, let or const)
* Disallows reassigning of const variables
* Duplicate param names not allowed in method
* Using with statement
* Using octal
* Declaring function in a block

“use strict”

Syntax:

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the difference between null and undefined

A

Null: It is usually used to mention of
absense of value of an object. Also the type of null is object and it needs to be assigned manually.

Undefined: It is assigned by default and indicates that the variable is not be initialized.
It also indicated the absense of the variable it self.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is difference between Window and Document

A

Window represents entire browser window and it is parent of all elements. You can use this object to alert(), get size of window etc.

Document which also known as Document Object Model (DOM) represents the page that is being loaded currently. You can get elements or modify them using this object. Fetch the object with window.document

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is an event flow

A

Event flow means how an event initiates and progresses to all the element in the DOM.

Two types
In Event bubbling the event starts from the target element and move up to all its parents and ends at DOM
In Event Capturing the event starts from DOM and completes at target element.

Default one is Event bubbling

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How do you redirect new page in javascript

A

You can use location object to redirect the user

window.location.href="newurl"

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How do you loop through or enumerate javascript object

A

Two ways:
1. (for key in obj) then do something with key
2. let keys=Object.keys(obj); then loop over keys array

Keep in mind that above will also include keys in parent object or prototype. Use obj.hasOwnProperty(key) along with above.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is an arguments object

A
  • Arguments object is available inside any js function without explicitly mentioning it.
  • You can use this object to get/loop through the argument being passed to function
  • Keep in mind that even though the argument object has some props of array, it is not an array. You can not use push, add or slice methods of array to arguments

Example:

function hello(){
      for( int i=0;i<arguments.length;i++){
			     console.log("Argument"+ ${i}+"=>"+${arguments[i]}`);
			}
}
hello(1,2,3);
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is a polyfill?

A
  • A polyfill is a way to provide backward compatibility in the browsers that does not support new features (i.e ECMAScript 2016).
  • In this cases you can provide fallback mechanism so that the feature work on all the browsers.

Example:

if(!Array.prototype.includes){
   Array.prototype.includes=function(element){
	    for(int i=0;i<this.length;i++){
			   if(this[i]==element){
				    return true;
				 }
			}
			return false;
	 }
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is App Shell model?

A
  • App Shell Model is used in PWA to give quick UI to the end user the show static content while dynamic content gets loaded.
  • This is helpful in slow network situation which ensures that the user has something to interect with
  • When App Shell is in place it gets loaded first with all static HTML, CSS and JS. After that the dynamic content gets loaded with Server side rendering and Client side JS
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is Tree Shaking?

A
  • Tree shaking is a way to remove unwanted or unused code and make an optimal bundle for production.
  • Tree Shaking algorithm uses module approach and discards unused modules to create small build
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is eval?

A

With eval() you can pass any code as string and it will be executed by js.

Example:

let x=1;
let y=5;
let exp='x+y';
let result=eval(exp);
console.log(result);

Use of eval should be avoided as it can lead to code injestion attacks, slow performances.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How do you detect mobile browser?

A
  1. Most browsers send User Agent in request so you can match the user agent string with known mobile browsers like below
if('/Android|webOS|iPad/'.test(navigator.userAgent)){
//mobile browser
} else{
// not a mobile browser
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Difference between “__proto__” and prototype

A

` __proto__ ` is used to get the reference of the prototype object of the current object. By using this you can check what methods are available with the prototype of current object.

prototype on the other hand is used to enhance the current constructor to add new methods or variables for existing function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is freeze method?

A

Object.freeze method is used to freeze the object/arrays, in other words to make them immutable.

"use strict"
let obj={ "name": "bac"};
Object.freeze(obj);
obj.age=23; // This will give error.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is a rest parameter?

A
  • A rest parameter is a special function parameter that can have unlimited number of arguments.
  • These arguments are stored in the form of an array.
  • Rest parameter is the last parameter of the function

Example:

function sum(...args){
   int sum=0;
   for(let num of args){
	     sum+=num;
	 }
	 return sum
}
sum(1,2);
sum(1,2,3,4);

If you don’t use rest param as last param in functon you will get // SyntaxError: Rest parameter must be last formal parameter error.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is spread operator?

A
  • Spread operator is mainly used with array or an object. It is somewhat reverse of rest parameter.
  • Purpose of this operator for array is to pass the elements of the array as individual elements in a function call.

Example:

const sum=(a,b,c)=>a+b+c;
let arr=[1,2,3]
sum(...arr) // 6
  • And in case of Object spread operator can be used to copy properties of one object to another hence to enhance the existing object.

Example:

let obj1= {name:"abc"}
let obj2={...obj1, city:"Pune"}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What is a proxy object

A

Proxy object is used to to define default behavior or fallback mechanism for the given object.

Example:

let handler= (obj,prop)=>{
      if(prop in obj){
			   return obj[prop]
			} else{
			   return 100; //default value
			}
};
let proxy=new Proxy({}, handler);
proxy.a=10;
proxy.b=200;

console.log(`${proxy.a}`);// 10
console.log(`${proxy.b}`);// 200
console.log(`${proxy.c}`);// 100 , default value
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What are the differences between freeze and seal methods

A

Object.freeze freeze the entire object so that you can not modify its existing properties and you can not add new properties.

Object.seal on the other hand only prevents adding new properties. You can modify existing ones.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What is WeakSet

A

WeakSet is similar to Set which is used to store unique objects. However, it has some limitations.
1. You can only store premitive objects ( int or strings are not allowed)
2. It will not prevent an object being garbage collected. If an object in the weakset is assign to null ref, it will be automatically deleted and garbage collected

Example:

const myWeakSet = new WeakSet();

const obj1 = { name: 'John' };
const obj2 = { name: 'Mary' };
const obj3 = { name: 'Bob' };

myWeakSet.add(obj1);
myWeakSet.add(obj2);

console.log(myWeakSet.has(obj1)); // true
console.log(myWeakSet.has(obj3)); // false

obj1 = null; // remove strong reference to obj1

// At this point, obj1 has no more strong references
// and can be garbage collected, even though it's still in myWeakSet

console.log(myWeakSet.has(obj1)); // false
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

What is anonymous function?

A

Anonymous function is a function having no name and usually assigned to a variable.

Examples:

let func1=function(){
   console.log("Func1");
}
func1(); // Func1

let funcArrow= ()=>{
   console.log("funcArrow");
}

funcArrow() // funcArrow
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What are the accessors?

A

Accessors are the getters and setters of the object.
* By introducing the accessors you can encaspsulate the setting and getting of the object and get control over it.
* However, you can not enforce the use of the accessors same as you do in java with private keyword.

Example:

var user = {
  firstName: "John",
  lastName : "Abraham",
  language : "en",
  get lang() {
    return this.language;
  },
  set lang(lang) {
  this.language = lang;
  }
};
console.log(user.lang); // getter access lang as en
user.lang = 'fr';
console.log(user.lang); // setter used to set lang as fr
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

What is Object.defineProperty

A

Object.defineProperty is used to to add or modify property of the object. Along with this you can also decide if the property is writable, enumerable or configurable.
* writable: if the property can be mutated
* configurable: if the property can be deleted or redefined
* enumerable: if the property can be visible in Object.keys() or for … in …

Example:

let obj={name:"abc"}
Object.defineProperty(obj,"newProp",{
   value: 123,
	 writable: true,
	 configurable: false,
	 enumerable: true
}

delete obj.newProp //error

You can also use getters and setters in the Object.defineProperty like below

const obj = {
  firstName: 'John',
  lastName: 'Doe'
};

Object.defineProperty(obj, 'fullName', {
  get: function() {
    return this.firstName + ' ' + this.lastName;
  },
  set: function(value) {
    const parts = value.split(' ');
    this.firstName = parts[0];
    this.lastName = parts[1];
  }
});

console.log(obj.fullName); // Output: "John Doe"

obj.fullName = "Jane Smith";
console.log(obj.firstName); // Output: "Jane"
console.log(obj.lastName); // Output: "Smith"
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

How do you define multiple properties to an object?

A

By using Object.defineProperties

Example:

let newObj={};
Object.defineProperties(newObj,{
newProp1:{
   value:1,
	 configurable:true
},
newProp2:{
   value:2,
	 configurable:false
}
});
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

What is nodejs

A

Nodejs is a Javascript runtime envirornment that allows running javascript code outside of a browser
* It uses javascript v8 engine developed by Google
* V8 is designed to compile and run js code quickly and efficiently. It uses JIT compiler that makes sure converting to machine code in runtime.

  • Along with this, NodeJs’ main applications are server side development, desktop apps and command line tools
25
Q

What is event loop

A

Event loop is a way to execute async tasks without blocking main thread or sync tasks
* In the context of js, event loop has two data structures

  1. Call stack
  2. Message queue
  • Call stack is used to identify the task to execute
  • Message queue is used to store pending tasks that will be executed after sync tasks are complete or the stack is empty

Example:

console.log('Starting...');

setTimeout(() => {
  console.log('Asynchronous timer callback');
}, 0);

Promise.resolve().then(() => {
  console.log('Promise resolved');
});

console.log('Ending...');

Output:

Starting...
Ending...
Promise resolved
Asynchronous timer callback

As you can see, console.log statements are executed in sync manner. So they are pushed to call stack immedietly.

On the other hand async operations such as promise and timer are pushed inside message queue. Once call stack is empty then queue will be polled to fetch the top element and will be executed .

This process occurs continuosly and handles the async process in single threaded env,

26
Q

What is a call stack

A

Call stack is the data structure used by js environment to keep track of function being executed.
* When a function is required to be executed it is pushed inside the stack, one the function returns value it is popped from stack
* When the function has another function call inside it, the new function will also be added to the stack and given priority.

Example:

function foo(){
   console.log("Inside foo");
	 bar();
	 console.log(" Existing foo");
}

function bar(){
   console.log("Inside bar");
}

foo();

Stack situation

1. foo() in stack
2. Execute   console.log("Inside foo");
3. bar() on top of stack
4. Execute  console.log("Inside bar");
5. Pop bar()
6. Execute  console.log(" Existing foo");
7. Pop foo()
27
Q

What is event queue

A

Event queue is used for async purposes.

  • When an async function is called lets say an api call, the call is made without waiting for the response
  • In the background, when Javascript runtime receives the response it puts the callback function inside the task queue
  • From here on, the event loop will pick the callback function from the queue and executes it
  • Thing to note here is that the callback of the async event is not pushed to queue untill the the async function is executed. Till that time the callback function is stored inside memory depending upon the type of async operation
  • For example, if it is timer type of async operation then the callback is stored in time heap based on minimum time, once time is expired it is pushed to task queue
28
Q

What is Obfuscation?

A

Obfuscation means to modify the source code in such a way that it will become hard to understand and reverse engineer.

  • This technique is used to prevent intelectual property right being stolen and to secure the codebase.
  • Along with this, minified version of the code is easy to transfer over internet hence improve performance of the application

There are several techniques for Obfuscation:

  • Non understandable variable names
  • Useless code that does not affect actual flow
  • Using encoding
  • Minification
29
Q

How do you modify the URL without causing full reload?

A

Changing value of window.location.href will cause full reload so that won’t work here.

Use history.pushState({}, "Title -1", "url-to-append") here
Param 1 is store some state object, param 2 is to show title in history UI and 3rd param is the actual url you want to append to existing url.

30
Q

What is namespace and how can you use it in js?

A

A namespace is a combination of classes, variables, functions etc. It is used so that we can combine different features and avoid collisions of names by putting them in different namespace

JS does not have any specific keyword for namespaces. However you can declare name spaces in following manner.

  1. By using let or const blocks
let namespace1={
  function hello(){
	   console.log("hello from namespace1");
	}
	
}

let namespace2={
  function hello(){
	   console.log("hello from namespace2");
	}
	
}
namespace1.hello();
namespace2.hello();
  1. Using IIFE with same function names but in different IIFE calls
  2. Using blocks since ES6
{
  function hello(){
	   console.log("hello from namespace1");
	}
	hello();
}

{
  function hello(){
	   console.log("hello from namespace2");
	}
	hello();
}
31
Q

What is an iframe?

A

When you want to show HTML content from completely different source than your original website, you can integrate iframe with below.

<iframe src="https://www.youtube.com" width="50" height="50"></iframe>

Keep in mind that integrating iframe comes with security drawbacks so use with caution.

32
Q

What are some features of ES6

A

ES6 Features:
1. Block scoped and immutable variables
2. Promises
3. Rest and Spread operators
4. Classes and Modules
5. Arrow functions

33
Q

What is Babel?

A

Babel is a transpiler that is used to convert input js code which can be written in latest ES6 syntax to browser compatible js

Babel helps reducing pollyfils so that developers can work on latest version of javascript without worrying backword compatibility.

34
Q

What are template literals

A

Basically this:
` Hi ${user}, good morning! `

35
Q

What is destructuring?

A

Destructuring was introduced in ES6 and is used to as a shorthand syntax to get specific field from the object or array.

  • You can also assign some default value to cover empty scenarios

Example for objects:

let obj1={ name: "ABC", age:20};
let {name, lastName="" }=obj;

Example for array:

let arr1= [1,2,3];
let [element1,element2]=arr1;
36
Q

What are enhanced object literals

A

Enahnced Object Literals provides shorthand syntax to set variables in objects with same name.

Example:

let name="abc"
let person={
   name,
	 age: 23,
	 hobby: "Cricket"
}
37
Q

Compare typed array with normal array

A

A regular js array is very dynamic to store any type of data any number of times. Though this is beneficial in general use it can slow down in case of huge chunk of data due to overhead.

Typed array on the other hand applies restrictions on type of elements and the number of elements. This increases performace as well as allows communication with other programming language like C++ or rust.

Typed array can also be benefical for cryptograhic operations and dealing with blockchain transactions.

Example:

const buffer = new ArrayBuffer(16);
 // allocate a 16-byte buffer

const intArray = new Int32Array(buffer); 
// create a 4-element Int32Array view

intArray[0] = 1; // set the first element to 1
intArray[1] = 2; // set the second element to 2

console.log(intArray); // output: Int32Array [ 1, 2, 0, 0 ]
38
Q

What is a module loader

A

Module loader is a component or library to add module to js.
It provides below benefits

  • Loading modules dynamically
  • Ensuring no modules have loaded more than once
  • Loading from disk or from network
  • Isolation from global namespace

Example from CommonJs:

const math = require('./math.js');

console.log(math.add(2, 3));       // Output: 5
console.log(math.subtract(5, 2));  // Output: 3

Example from import from ES6:

import { add, subtract } from './math.js';

console.log(add(2, 3));       // Output: 5
console.log(subtract(5, 2));  // Output: 3
39
Q

Difference between require() and import

A
  • require() is provided by CommonJs and usually available in Nodejs env, however it might not be available in all the modern browsers.
    import on the other hand is a statement provided from ES6 so it usually available in all modern browsers.
  • require() adds modules dynamically on runtime and synchronous manner, import adds modules statically in async manner

Example to import default export with CommonJS

const mathDefaultOperation= require('./math.js').default;

mathDefaultOperation(1,2) // will executed default method exported by math

Example to import default export with ES6:
(no curly braces compared to named export)

import mathDefaultOperation from './math.js'

mathDefaultOperation(1,2) // will executed default method exported by math
40
Q

Difference between Named export and Default export

A

In JS you can export functions or variables of a module in 2 ways
1. Named export : This way you can export as much elements of the modules as you want
2. Default export: You can export only one export as default export. Benefit of this being that you might not know what the name of the function a module exports and still you can call this function with your own alias without any syntax change

Example named export:

// module.js
export const add = (a, b) => a + b;
export const subtract = (a, b) => a - b;

// other-module.js
import { add, subtract } from './module.js';

console.log(add(1, 2)); // 3
console.log(subtract(3, 1)); // 2

Example default export:

// module.js
const greeting = 'Hello, world!';
export default greeting;

// other-module.js
import myGreeting from './module.js';
console.log(myGreeting); // "Hello, world!"
41
Q

What is collation

A

Collation simply means sorting and searching elements in a list of strings based on their unicode valiue.

Why unicode? as it supports wide varietly of symbols including multi language support including Hindi and Gujarati .

42
Q

What is paradigm in terms of Js

A

Paradigm means pattern. Below are some of the pattern of programming supported by JS
1. Object oriented
2. Procedure oriented: Dividing function into small function calls
3. Function oriented: Functions are considered as a main objects of js and can do pretty much everything with them
4. Event driven: All kinds of events weather api related async events, timer or user action based events are handled by js.

So this means JS is a multi paradigm programming language

43
Q

Difference between reflow and repaint

A

Repaint as it says from the word is just color, bgcolor or outline change of elements

Reflow means chaging of layout of DOM by adding, removing elements or changing class name of the elements. This results in DOM tree changes hence its called reflow.

44
Q

Convert array to object

A
const countries = [
    "India", "USA", "Australia"
];

const cityNames = { ...countries }
console.log(cityNames); // { '0': 'India', '1': 'USA', '2': 'Australia' }
45
Q

How do you flatten an array in js

A

Best way is to use Array.flat method like below

  • For 2 dimension
    ~~~
    const arr = [1, [2, 3], 4, 5, [6, 7]];
    const fllattenArr = arr.flat(); // [1, 2, 3, 4, 5, 6, 7]
    ~~~
  • For n dimension:
const arr = [1, [2, 3], 4, 5, [6, [7]]];
const fllattenArr = arr.flat(Infinity); // [1, 2, 3, 4, 5, 6, 7]
46
Q

If string is of premitive type why can you perform operations like toUpperCase on it?

A

Thats because when you do str.toUpperCase() internally the string is converted into new String(str). This is called Wrapper objects and it is available for all the types except null and undefined.

47
Q

How do you abort a fetch request?

A

By using AbortController you can pass AbortSignal to fetch api, internally when fetch api makes a call it parallely listens to event being thrown to AbortSignal if it receives the signal before the api response, it will abort the request.

Example:

let controller=new AbortController();
let signal=controller.signal;

fetch("http://abc.com", {signal})
.then (res=> //got response)
.err(err=>{
   if(err.name=="AbortError"){
	   // Operation aborted
	 }
 });

// Wait 2 seconds to abort  requests
setTimeout(() => controller.abort(), 2000);

// This will abort all the request to which //controller signal was passed
48
Q

What is minimum timeout throttling?

A

Minimum timeout throttling is a technique used to prevent repetative network calls or to stop overloading the server.

  • Modern browser have minimum timeout of 4ms, which means they wait for 4ms before calling each next operation
  • NodeJs has 1ms timeout
  • You can also configure your own throttle with settimeout
49
Q

What is a microtask?

A

Microtask is a special type of task that has higher priority. The task will be executed immedietly after whatever current task is getting executed.

Also keep in mind that microtasks are stored in microtask queue which is given priority to normal task queue.

Promise.resolve and Promise.reject are examples for microtask

50
Q

What is the difference between shim and polyfill?

A

All polyfill are shims but not all shims are polyfills.
shim is a terminology that provides ability to make new features available in old browsers or any other system.

polyfills are type of a shim but they are only available in browsers.

51
Q

Is Node.js completely single threaded

A

Node.js is primarily single threaded as it uses single threaded event loop for async operations.

However, when this async operations are being executed, js paralely does many thing which are happening in different threads or cores, hence it is not single threaded.

Along with this it can also run web workers or service worker for background sync or CPU intensive operations.

52
Q

What is the difference between function and class declarations

A
  1. Function declaration are hoisted to the top of its scope so that they can be used before they are declared in code . Class declarations are not hoisted
  2. Syntax difference
  3. You can use inheritance for Class, for Function you need prototype
53
Q

What is error swallowing?

A

Error swallowing is an anti pattern when a developer miss to handle or catch the error properly. This results in untracabled situations.

You can avoid this by

  • Adding catch statement to all promise handling
  • using try catch in async and await statements
54
Q

What is a proper tail call?

A

Tail call is basically recursion where you make recursive call as a last statement of the function.

Example:

function factorial(n) {
  if (n === 1) {
    return 1;
  } else {
    return n * factorial(n - 1);
  }
}

But the problem with above is that it needs to wait for recursion to complete and multiply the result with n. This will require additional stacks to be created and preserved.

Now a Proper tail call is a way to prevent extra stacks to be created by just executing the recursive call and pass the result in accumulated way.

Example:

function factorial(n, acc=1){
   if(n==0){
	    return acc;
	 }
	 return factorial(n-1, n*acc);
}
55
Q

What is generator function?

A

Generator is special type of function to generate or yield a value

Example:

function* sequence() {
    let i = 0;
    while (true) {
        yield i;
        i++;
    }
}
let gen = sequence();
console.log(gen.next().value); //0
console.log(gen.next().value); //1

Here the loop execution will stop at yield and return the value. After that it will continue execution.

56
Q

What is the difference between setTimeout, setImmediate and process.nextTick

A
  • setTimeout: execute a function after specified delay in ms
  • setImmediate: execute a function as soon as possible on the next iteration of event loop
  • process.nextTick: execute a function immediatley after current function execution is over without waiting queue iteration to complete

process.nextTick > setImmediate > setTimeout

57
Q

What is global execution context?

A

Global execution context is a starting point of javascript execution.
All the code or variable which are not part of any functions or blocks become part of global context.

When a function is called from global context then current context becomes the function context. Once function execution is complete, the context changes to global context.

58
Q

What is debouncing?

A

Debouncing is a way to prevent frequent function invocations. These function invocations can happen due to search, scroll or click events.

A good example of debouncing would be search some data from server. Usually in these situations data needs to be fetched from server on any text change. If user writes too quickly then it can flood the server with redundant requests.

To solve above, you can setup a timer before making call to the server. If another event is received before the timer is expired, you reset the timer and update the query. Once timer is expired, then only you make a call to server to fetch data.

Example:

const searchInput = document.getElementById('search-input');

let debounceTimer;
const debounceDelay = 500;

searchInput.addEventListener('input', function() {
  clearTimeout(debounceTimer);
  debounceTimer = setTimeout(() => {
    const query = searchInput.value;
    // do something with the search query, such as send a request to a server or filter a list
    console.log('Search query:', query);
  }, debounceDelay);
});
59
Q

What is throttling?

A

Throttling is also used for limiting function calls but unlike Debouncing, it will not delay function execution. It won’t use setTimeout. Instead it will set a limit on function calls being made in certain duration.

It sounds similar but since it does not use setTimeout, the function call is made from stack and does not go into event loop.

Example wise, throttling can be used for scroll events when we can not delay function invocation to get the data. Instead we can limit function invocation so that in regular interval we can get the data. If we use Debounce on scroll it will have impact on UI as user will see stuck screen before data.

Example:

function throttle(func, delay) {
  let lastCallTime = 0;
  return function() {
    const context = this;
    const args = arguments;
    const now = Date.now();
    if (now - lastCallTime >= delay) {
      func.apply(context, args);
      lastCallTime = now;
    }
  }
}

const scrollContainer = document.getElementById('scroll-container');
scrollContainer.addEventListener('scroll', throttle(() => {
  console.log('Scrolled');
}, 500));