UNPKG

interview-questions

Version:

A CLI tool for generating interview questions by difficulty level and quantity, with support for multiple output formats including text, JSON, and arrays.

672 lines 405 kB
[ { "title": "What is IndexedDB", "url": "https://www.tiktok.com/@jsmentoring/photo/7448276165661314336", "level": "basic", "theme": "IndexedDB, db, storage", "text": "### What is IndexedDB?\n\nIndexedDB is a low-level API for storing large amounts of structured data, including files and blobs. It allows developers to perform advanced queries and store data persistently in a user's browser. This API is particularly useful for web applications that need to work offline or require local storage beyond simple key-value pairs.", "link": "#what-is-indexeddb" }, { "title": "What are the options in a cookie", "url": "https://www.tiktok.com/@jsmentoring/photo/7448261980567145761", "level": "basic", "theme": "cookie, options, storage", "text": "### What are the options in a cookie?\n\nCookies have several options to control their behavior, such as `path`, `domain`, `secure`, `HttpOnly`, and `SameSite`. These options help define the scope, security, and accessibility of the cookie.", "link": "#what-are-the-options-in-a-cookie" }, { "title": "Differences between cookie, local storage and session storage", "url": "https://www.tiktok.com/@jsmentoring/photo/7448258461030173985", "level": "basic", "theme": "cookie, local storage, session storage, differences", "text": "### Differences between cookie, local storage, and session storage\n\nCookies are primarily used for server communication and have size limitations. Local storage provides persistent client-side storage with no expiration, while session storage stores data for the duration of a session.", "link": "#differences-between-cookie-local-storage-and-session-storage" }, { "title": "How do you delete a cookie", "url": "https://www.tiktok.com/@jsmentoring/photo/7448236859966197025", "level": "intermediate", "theme": "cookie, delete, remove", "text": "### How do you delete a cookie?\n\nTo delete a cookie, set its expiration date to a past date using the `Set-Cookie` header or JavaScript's `document.cookie`. Ensure you match the path and domain attributes of the cookie.", "link": "#how-do-you-delete-a-cookie" }, { "title": "What is a post message", "url": "https://www.tiktok.com/@jsmentoring/photo/7448205399074934049", "level": "intermediate", "theme": "postMessage, communication, iframe", "text": "### What is a post message?\n\nThe `postMessage` API allows secure communication between a parent window and iframes or between different windows. It is commonly used for cross-origin communication in web applications.", "link": "#what-is-a-post-message" }, { "title": "What are closures", "url": "https://www.tiktok.com/@jsmentoring/photo/7447942704148811041", "level": "intermediate", "theme": "closures, JavaScript, scope", "text": "### What are closures?\n\nClosures in JavaScript occur when a function retains access to its lexical scope even after the function in which it was defined has completed execution. They enable powerful programming patterns like encapsulation and callbacks.", "link": "#what-are-closures" }, { "title": "What are modules", "url": "https://www.tiktok.com/@jsmentoring/photo/7447936859029654816", "level": "intermediate", "theme": "modules, JavaScript, ES6", "text": "### What are modules?\n\nModules are reusable blocks of code that can be imported and exported in JavaScript. They help organize and encapsulate functionality, promoting maintainable and modular codebases.", "link": "#what-are-modules" }, { "title": "What are classes in ES6", "url": "https://www.tiktok.com/@jsmentoring/photo/7447909741977685280", "level": "advanced", "theme": "classes, ES6, object-oriented programming", "text": "### What are classes in ES6?\n\nClasses in ES6 provide a syntax for object-oriented programming in JavaScript. They include constructors, methods, and inheritance, making it easier to create and manage objects.", "link": "#what-are-classes-in-es6" }, { "title": "Why do you need modules", "url": "https://www.tiktok.com/@jsmentoring/photo/7447895686626020640", "level": "intermediate", "theme": "modules, benefits, organization", "text": "### Why do you need modules?\n\nModules help organize code into manageable pieces, improve reusability, and avoid global namespace pollution. They also make dependency management and code maintenance easier.", "link": "#why-do-you-need-modules" }, { "title": "What is Hoisting", "url": "https://www.tiktok.com/@jsmentoring/photo/7447882385946938656", "level": "basic", "theme": "hoisting, JavaScript, scope", "text": "### What is Hoisting?\n\nHoisting in JavaScript refers to the process where variable and function declarations are moved to the top of their scope during compilation. This allows variables to be used before they are declared.", "link": "#what-is-hoisting" }, { "title": "What is scope in javascript", "url": "https://www.tiktok.com/@jsmentoring/photo/7447877473280265505", "level": "basic", "theme": "scope, JavaScript, variables", "text": "### What is scope in JavaScript?\\n\\nScope determines the accessibility of variables and functions in JavaScript. There are two types of scope: global and local. Modern JavaScript also includes block scope with \\`let\\` and \\`const\\`.", "link": "#what-is-scope-in-javascript" }, { "title": "What is a service worker", "url": "https://www.tiktok.com/@jsmentoring/photo/7447871707219594529", "level": "advanced", "theme": "service worker, offline, caching", "text": "### What is a service worker?\n\nA service worker is a script that runs in the background, separate from the web page, enabling features like offline functionality, push notifications, and background sync. It acts as a proxy between the web app and the network.", "link": "#what-is-a-service-worker" }, { "title": "How do you manipulate with DOM element", "url": "https://www.tiktok.com/@jsmentoring/photo/7447865971974475041", "level": "basic", "theme": "DOM manipulation, JavaScript, elements", "text": "### How do you manipulate a DOM element?\n\nTo manipulate DOM elements, use methods like `document.getElementById`, `document.querySelector`, and properties like `.innerHTML`, `.style`, or methods like `appendChild` and `removeChild` to modify elements dynamically.", "link": "#how-do-you-manipulate-with-dom-element" }, { "title": "How do you reuse information across service worker restarts", "url": "https://www.tiktok.com/@jsmentoring/photo/7447841580880350497", "level": "advanced", "theme": "service worker, persistence, IndexedDB", "text": "### How do you reuse information across service worker restarts?\n\nTo reuse information across service worker restarts, store data in persistent storage mechanisms like IndexedDB or localStorage. This ensures data remains accessible even when the service worker restarts.", "link": "#how-do-you-reuse-information-across-service-worker-restarts" }, { "title": "What is IndexedDB", "url": "https://www.tiktok.com/@jsmentoring/photo/7447814335323278624", "level": "advanced", "theme": "IndexedDB, database, storage", "text": "### What is IndexedDB?\n\nIndexedDB is a low-level API for storing large amounts of structured data, including files and blobs. It allows advanced querying and persistent storage, making it ideal for offline-capable applications.", "link": "#what-is-indexeddb" }, { "title": "What is memoization", "url": "https://www.tiktok.com/@jsmentoring/photo/7447658154155871520", "level": "intermediate", "theme": "memoization, caching, performance", "text": "### What is memoization?\n\nMemoization is an optimization technique where function results are cached based on input arguments, avoiding redundant computations and improving performance.", "link": "#what-is-memoization" }, { "title": "What is memoization", "url": "https://www.tiktok.com/@jsmentoring/photo/7447658154155871520", "level": "intermediate", "theme": "memoization, caching, performance", "text": "### What is memoization?\n\nMemoization is an optimization technique where function results are cached based on input arguments, avoiding redundant computations and improving performance.", "link": "#what-is-memoization" }, { "title": "What is a Prototype Chain in JavaScript?", "url": "https://www.tiktok.com/@jsmentoring/photo/7447534074211601697", "level": "basic", "theme": "prototype, inheritance, JavaScript", "text": "### What is a Prototype Chain in JavaScript?\n\nThe prototype chain is a fundamental concept in JavaScript's inheritance model. Every object in JavaScript has a prototype, which is another object. When you access a property of an object, JavaScript will first look for it in the object itself. If not found, it will look in the object's prototype, and then the prototype's prototype, and so on, until it reaches `null`.", "link": "#what-is-a-prototype-chain-in-javascript" }, { "title": "What is a higher order function", "url": "https://www.tiktok.com/@jsmentoring/photo/7447469800642727200", "level": "intermediate", "theme": "higher order functions, JavaScript", "text": "### What is a higher order function?\n\nA higher order function is a function that either takes one or more functions as arguments, returns a function, or both. This allows for more abstract and reusable code. Examples of higher order functions include `map()`, `filter()`, and `reduce()` in JavaScript.", "link": "#what-is-a-higher-order-function" }, { "title": "What is the currying function", "url": "https://www.tiktok.com/@jsmentoring/photo/7447172210076208417", "level": "advanced", "theme": "currying, functions, JavaScript", "text": "### What is the currying function?\n\nCurrying is a technique in functional programming where a function that takes multiple arguments is transformed into a sequence of functions, each taking a single argument. This can make the code more modular and reusable. For example, `function add(a) { return function(b) { return a + b; } }`.", "link": "#what-is-the-currying-function" }, { "title": "How do you compare Object and Map", "url": "https://www.tiktok.com/@jsmentoring/photo/7447122335863147808", "level": "advanced", "theme": "Object, Map, JavaScript", "text": "### How do you compare Object and Map?\n\nBoth `Object` and `Map` are key-value stores in JavaScript, but they have differences:\n\n1. **Key Types**: `Map` can use any data type as a key, while `Object` keys are always converted to strings.\n2. **Iteration**: `Map` preserves the order of insertion, while `Object` does not guarantee order.\n3. **Performance**: `Map` is generally more efficient for frequent additions and removals of key-value pairs.", "link": "#how-do-you-compare-object-and-map" }, { "title": "What is a pure function", "url": "https://www.tiktok.com/@jsmentoring/photo/7447104096424725792", "level": "advanced", "theme": "pure function, functional programming", "text": "### What is a pure function?\n\nA pure function is a function that, given the same input, will always return the same output and does not have any side effects. It does not modify any external state or depend on external variables. This makes pure functions predictable and easier to test, as well as a key concept in functional programming.", "link": "#what-is-a-pure-function" }, { "title": "What is a Prototype Chain in JavaScript?", "url": "https://www.tiktok.com/@jsmentoring/photo/7446735468848270625", "level": "basic", "theme": "prototype, inheritance, JavaScript", "text": "### What is a Prototype Chain in JavaScript?\n\nThe prototype chain is a fundamental concept in JavaScript's inheritance model. Every object in JavaScript has a prototype, which is another object. When you access a property of an object, JavaScript will first look for it in the object itself. If not found, it will look in the object's prototype, and then the prototype's prototype, and so on, until it reaches `null`.", "link": "#what-is-a-prototype-chain-in-javascript" }, { "title": "What is the purpose of the let keyword", "url": "https://www.tiktok.com/@jsmentoring/photo/7446499450626772256", "level": "basic", "theme": "let keyword, JavaScript", "text": "### What is the purpose of the let keyword?\n\nThe `let` keyword in JavaScript is used to declare block-scoped variables. Unlike `var`, which declares variables globally or within a function scope, `let` restricts the variable's scope to the block, statement, or expression in which it is used. This makes `let` more predictable and avoids issues with variable hoisting.", "link": "#what-is-the-purpose-of-the-let-keyword" }, { "title": "Arrow func?", "url": "https://www.tiktok.com/@jsmentoring/photo/7446420047448247585", "level": "basic", "theme": "arrow functions, JavaScript", "text": "### Arrow func?\n\nArrow functions in JavaScript are a shorter syntax for writing functions. They are defined using `=>` and do not have their own `this` value, which means they inherit `this` from the surrounding context. This makes them useful in situations like event handling and callbacks where `this` behavior can be tricky.", "link": "#arrow-func" }, { "title": "What is the difference between let and var", "url": "https://www.tiktok.com/@jsmentoring/photo/7446417854699687200", "level": "basic", "theme": "let, var, JavaScript", "text": "### What is the difference between let and var?\n\nThe primary differences between `let` and `var` are their scoping rules and hoisting behavior:\n\n1. **Scope**: `let` is block-scoped, while `var` is function-scoped.\n2. **Hoisting**: Both `let` and `var` are hoisted to the top of their scope, but `let` is not initialized until the code execution reaches it, leading to a Temporal Dead Zone (TDZ).", "link": "#what-is-the-difference-between-let-and-var" }, { "title": "What is git bisect command?", "url": "https://www.tiktok.com/@jsmentoring/photo/7446337497484791073", "level": "advanced", "theme": "git, bisect, debugging", "text": "### What is git bisect command?\n\nThe `git bisect` command is used to find the commit that introduced a bug by performing a binary search. You start by marking a known good commit and a known bad commit. Git then checks out the midpoint commit, and you test it. Based on the result, Git narrows down the range of commits until the problematic one is found.", "link": "#what-is-git-bisect-command" }, { "title": "What are lambda expressions or arrow functions?", "url": "https://www.tiktok.com/@jsmentoring/photo/7446080608989678880", "level": "basic", "theme": "lambda expressions, arrow functions, JavaScript", "text": "### What are lambda expressions or arrow functions?\n\nLambda expressions, also known as arrow functions, are a concise way to write functions in JavaScript. They use the `=>` syntax and do not have their own `this` value, meaning they inherit `this` from the surrounding context. They are often used for short, anonymous functions in callbacks or array methods.", "link": "#what-are-lambda-expressions-or-arrow-functions" }, { "title": "What is the difference between == and === operators?", "url": "https://www.tiktok.com/@jsmentoring/photo/7446055928723508512", "level": "basic", "theme": "JavaScript", "text": "### What is the difference between == and === operators?\n\nIn JavaScript, `==` is the equality operator that compares values after performing type coercion, meaning it converts the values to a common type before comparing them. On the other hand, `===` is the strict equality operator, which compares both the value and the type without any type conversion.", "link": "#what-is-the-difference-between-and-operators" }, { "title": "What is the purpose of the array splice method?", "url": "https://www.tiktok.com/@jsmentoring/photo/7446035575565520160", "level": "basic", "theme": "splice, array, JavaScript", "text": "### What is the purpose of the array splice method?\n\nThe `splice()` method in JavaScript is used to modify an array by adding, removing, or replacing elements. It takes at least two arguments: the index at which to start changing the array, and the number of elements to remove. Additional arguments can be provided to add new elements.", "link": "#what-is-the-purpose-of-the-array-splice-method" }, { "title": "What is the difference between slice and splice?", "url": "https://www.tiktok.com/@jsmentoring/photo/7446029933446565152", "level": "basic", "theme": "slice, splice, JavaScript", "text": "### What is the difference between slice and splice?\n\n`slice()` is used to extract a shallow copy of a portion of an array without modifying the original array, while `splice()` is used to change the contents of an array by removing or replacing elements. The key difference is that `slice()` does not alter the array, while `splice()` does.", "link": "#what-is-the-difference-between-slice-and-splice" }, { "title": "5 Ways to Create Objects in JavaScript?", "url": "https://www.tiktok.com/@jsmentoring/photo/7445448146685136161", "level": "basic", "theme": "objects, creation, JavaScript", "text": "### 5 Ways to Create Objects in JavaScript\n\nIn JavaScript, objects can be created in various ways. The five most common methods are:\n\n1. **Object Literal**: `const obj = {}`\n2. **Object Constructor**: `const obj = new Object()`\n3. **Object.create()**: `const obj = Object.create(null)`\n4. **Class Syntax**: `class MyClass { constructor() {} }`\n5. **Factory Functions**: `function createObject() { return {}}`", "link": "#5-ways-to-create-objects-in-javascript" }, { "title": "What is git rebase command?", "url": "https://www.tiktok.com/@jsmentoring/photo/7444874869394771232", "level": "basic", "theme": "git, rebase, version control", "text": "### What is git rebase command?\n\nThe `git rebase` command is used to integrate changes from one branch into another. It works by moving or 'replaying' commits from one branch onto another, creating a linear history. This is different from `git merge`, which creates a merge commit. `git rebase` can be used to keep a cleaner, more linear commit history.", "link": "#what-is-git-rebase-command" }, { "title": "What is git reflog command?", "url": "https://www.tiktok.com/@jsmentoring/photo/7444873101717884192", "level": "basic", "theme": "git, reflog, version control", "text": "### What is git reflog command?\n\nThe `git reflog` command is used to show the history of changes to the reference logs, which track updates to the branches in a repository. This can be useful for recovering lost commits or understanding the changes made to a branch, especially after actions like rebasing or resetting.", "link": "#what-is-git-reflog-command" }, { "title": "What is git revert command?", "url": "https://www.tiktok.com/@jsmentoring/photo/7444867368431439136", "level": "basic", "theme": "git, revert, version control", "text": "### What is git revert command?\n\nThe `git revert` command is used to create a new commit that undoes the changes made by a previous commit. Unlike `git reset`, which alters the commit history, `git revert` preserves the commit history and is often used in shared repositories to undo changes safely.", "link": "#what-is-git-revert-command" }, { "title": "What is a storage event and its event handler?", "url": "https://www.tiktok.com/@jsmentoring/photo/7448353911720742177", "level": "intermediate", "theme": "storage event, event handler, web storage", "text": "### What is a storage event and its event handler?\n\nA storage event is triggered when a change is made to the `localStorage` or `sessionStorage` in the browser, such as adding, removing, or modifying a key-value pair. The event handler for this event allows you to respond to these changes, providing a way to synchronize or react to storage updates across different windows or tabs.", "link": "#what-is-a-storage-event-and-its-event-handler" }, { "title": "What are the methods available on session storage?", "url": "https://www.tiktok.com/@jsmentoring/photo/7448368128825888032", "level": "basic", "theme": "sessionStorage, web storage", "text": "### What are the methods available on session storage?\n\n`sessionStorage` provides methods to interact with the browser's session storage. Key methods include:\n\n- `setItem(key, value)`: Adds a key-value pair.\n- `getItem(key)`: Retrieves the value for a given key.\n- `removeItem(key)`: Removes the key-value pair.\n- `clear()`: Clears all data stored in sessionStorage.", "link": "#what-are-the-methods-available-on-session-storage" }, { "title": "How do you access web storage?", "url": "https://www.tiktok.com/@jsmentoring/photo/7448375078183587105", "level": "basic", "theme": "web storage, sessionStorage, localStorage", "text": "### How do you access web storage?\n\nWeb storage is accessed using the `localStorage` or `sessionStorage` objects in JavaScript. For example, you can use `localStorage.setItem('key', 'value')` to store data, and `localStorage.getItem('key')` to retrieve it. Both `localStorage` and `sessionStorage` are part of the Window interface and provide a simple API for storing key-value pairs.", "link": "#how-do-you-access-web-storage" }, { "title": "What is the main difference between localStorage and sessionStorage?", "url": "https://www.tiktok.com/@jsmentoring/photo/7448379916778851617", "level": "basic", "theme": "localStorage, sessionStorage, web storage", "text": "### What is the main difference between localStorage and sessionStorage?\n\nThe main difference is the lifespan of the stored data:\n- **`localStorage`** persists data even after the browser is closed, and the data remains available until explicitly removed.\n- **`sessionStorage`** only stores data for the duration of the page session. Once the tab or window is closed, the data is cleared.", "link": "#what-is-the-main-difference-between-localstorage-and-sessionstorage" }, { "title": "Why do you need a Cookie?", "url": "https://www.tiktok.com/@jsmentoring/photo/7448385477113171233", "level": "intermediate", "theme": "cookies, web storage, HTTP", "text": "### Why do you need a Cookie?\n\nCookies are used to store data on the client-side, typically for purposes like tracking user sessions, saving preferences, or authenticating users. They are sent to the server with every HTTP request, allowing the server to remember information about the client across requests and sessions.", "link": "#why-do-you-need-a-cookie" }, { "title": "What is a Cookie?", "url": "https://www.tiktok.com/@jsmentoring/photo/7448395347279236384", "level": "basic", "theme": "cookies, web storage, HTTP", "text": "### What is a Cookie?\n\nA cookie is a small piece of data stored by the browser on the client-side. It is sent to the server with every HTTP request and is used for various purposes such as maintaining user sessions, tracking user activity, and storing preferences.", "link": "#what-is-a-cookie" }, { "title": "What is web storage?", "url": "https://www.tiktok.com/@jsmentoring/photo/7448401312728878368", "level": "basic", "theme": "web storage, localStorage, sessionStorage", "text": "### What is web storage?\n\nWeb storage provides a way to store data in the browser. It includes two types: `localStorage` and `sessionStorage`. `localStorage` stores data persistently, while `sessionStorage` stores data for the duration of a session, which is cleared when the browser or tab is closed.", "link": "#what-is-web-storage" }, { "title": "What Are Server-Sent Events (SSE)?", "url": "https://www.tiktok.com/@jsmentoring/photo/7448434434774142240", "level": "intermediate", "theme": "SSE, real-time communication, web technologies", "text": "### What Are Server-Sent Events (SSE)?\n\nServer-Sent Events (SSE) is a technology that allows a server to push updates to the client over a single HTTP connection. This is typically used for real-time applications such as notifications, live scores, or chat apps, where the server sends updates to the client automatically.", "link": "#what-are-server-sent-events-sse" }, { "title": "What Is a Callback Hell?", "url": "https://www.tiktok.com/@jsmentoring/photo/7448549870673169696", "level": "intermediate", "theme": "callback hell, asynchronous, JavaScript", "text": "### What Is a Callback Hell?\n\nCallback hell, also known as 'Pyramid of Doom,' refers to a situation where multiple nested callback functions in JavaScript make the code hard to read and maintain. It usually occurs in asynchronous code and can be mitigated by using Promises or async/await.", "link": "#what-is-a-callback-hell" }, { "title": "Importance of Callbacks in Javascript?", "url": "https://www.tiktok.com/@jsmentoring/photo/7448582345390591265", "level": "basic", "theme": "callbacks, JavaScript, asynchronous programming", "text": "### Importance of Callbacks in Javascript?\n\nCallbacks in JavaScript are functions passed as arguments to other functions, enabling asynchronous programming. They allow for non-blocking code execution, making it possible to handle events like user input or network requests without freezing the application.", "link": "#importance-of-callbacks-in-javascript" }, { "title": "What is a callback function in javascript?", "url": "https://www.tiktok.com/@jsmentoring/photo/7448614606278282529", "level": "basic", "theme": "callback function, JavaScript, asynchronous programming", "text": "### What is a callback function in javascript?\n\nA callback function is a function passed into another function as an argument and executed after the completion of a task. Callbacks are commonly used in asynchronous programming, such as handling events or making HTTP requests.", "link": "#what-is-a-callback-function-in-javascript" }, { "title": "What Are the Three States of a Promise?", "url": "https://www.tiktok.com/@jsmentoring/photo/7448655823150058785", "level": "intermediate", "theme": "Promise, JavaScript, asynchronous programming", "text": "### What Are the Three States of a Promise?\n\nA Promise in JavaScript can be in one of three states:\n- **Pending**: The initial state, neither fulfilled nor rejected.\n- **Fulfilled**: The operation completed successfully.\n- **Rejected**: The operation failed.", "link": "#what-are-the-three-states-of-a-promise" }, { "title": "Why do you need a promise?", "url": "https://www.tiktok.com/@jsmentoring/photo/7448671709634235681", "level": "intermediate", "theme": "Promise, asynchronous programming", "text": "### Why do you need a promise?\n\nPromises are used to handle asynchronous operations in JavaScript. They provide a cleaner way to handle asynchronous code, avoiding callback hell by chaining `.then()` and `.catch()` methods to handle success and failure, respectively.", "link": "#why-do-you-need-a-promise" }, { "title": "What is a promise?", "url": "https://www.tiktok.com/@jsmentoring/photo/7448715825642540320", "level": "intermediate", "theme": "Promise, JavaScript, asynchronous programming", "text": "### What is a promise?\n\nA promise is an object in JavaScript that represents the eventual completion (or failure) of an asynchronous operation and its resulting value. It allows you to attach `.then()` and `.catch()` methods to handle the results or errors of the asynchronous task.", "link": "#what-is-a-promise" }, { "title": "What are the restrictions of web workers on DOM?", "url": "https://www.tiktok.com/@jsmentoring/photo/7448725365574372641", "level": "advanced", "theme": "web workers, DOM, JavaScript", "text": "### What are the restrictions of web workers on DOM?\n\nWeb workers run in a separate thread and cannot directly access or modify the DOM. They are designed for heavy computations and background tasks. To interact with the DOM, workers communicate with the main thread using message passing via `postMessage()`.", "link": "#what-are-the-restrictions-of-web-workers-on-dom" }, { "title": "Give an example of a web worker?", "url": "https://www.tiktok.com/@jsmentoring/photo/7448739040213437729", "level": "intermediate", "theme": "web workers, JavaScript", "text": "### Give an example of a web worker?\n\nA simple web worker example:\n\n```javascript\nconst worker = new Worker('worker.js');\nworker.postMessage('Hello');\nworker.onmessage = function(event) {\n console.log('Received from worker:', event.data);\n};\n```\nIn the `worker.js` file, you would handle the message with `onmessage` and use `postMessage` to send a response back.", "link": "#give-an-example-of-a-web-worker" }, { "title": "How do you check web storage browser support?", "url": "https://www.tiktok.com/@jsmentoring/photo/7448750198848769313", "level": "basic", "theme": "web storage, browser support, JavaScript", "text": "### How do you check web storage browser support?\n\nTo check if a browser supports web storage, you can check if `localStorage` or `sessionStorage` is available:\n\n```javascript\nif (typeof(Storage) !== 'undefined') {\n // Web storage is supported\n} else {\n // Web storage is not supported\n}\n```", "link": "#how-do-you-check-web-storage-browser-support" }, { "title": "Why do you need web storage?", "url": "https://www.tiktok.com/@jsmentoring/photo/7448934582965046561", "level": "basic", "theme": "web storage, JavaScript", "text": "### Why do you need web storage?\n\nWeb storage allows you to store data on the client side, providing faster access to information without requiring a round-trip to the server. It helps with tasks like saving user preferences, session information, and caching data for offline use.", "link": "#why-do-you-need-web-storage" }, { "title": "How Do You Receive Server-Sent Event Notifications?", "url": "https://www.tiktok.com/@jsmentoring/photo/7448989685881376033", "level": "intermediate", "theme": "Server-Sent Events, notifications, web technologies", "text": "### How Do You Receive Server-Sent Event Notifications?\n\nTo receive Server-Sent Event (SSE) notifications, you need to create an `EventSource` object in JavaScript, which listens for events sent by the server. For example:\n\n```javascript\nconst eventSource = new EventSource('https://example.com/sse');\neventSource.onmessage = function(event) {\n console.log('New message:', event.data);\n};\n```", "link": "#how-do-you-receive-server-sent-event-notifications" }, { "title": "What Is a Callback in Callback?", "url": "https://www.tiktok.com/@jsmentoring/photo/7449011382449720608", "level": "intermediate", "theme": "callbacks, asynchronous programming, JavaScript", "text": "### What Is a Callback in Callback?\n\nA 'callback in callback' refers to a situation where a function is passed as a parameter to another function, and that function in turn calls another function (callback) within it. This can lead to nested callbacks, which may result in 'callback hell' if not managed properly.", "link": "#what-is-a-callback-in-callback" }, { "title": "What Is Promise Chaining in JavaScript?", "url": "https://www.tiktok.com/@jsmentoring/photo/7449040289345457441", "level": "intermediate", "theme": "Promises, JavaScript, asynchronous programming", "text": "### What Is Promise Chaining in JavaScript?\n\nPromise chaining allows you to chain multiple `.then()` calls to handle sequential asynchronous operations. Each `.then()` returns a new promise, enabling the next step in the chain to execute after the previous one is fulfilled.\n\n```javascript\nfetchData()\n .then(result => processData(result))\n .then(processedData => displayData(processedData))\n .catch(error => console.error(error));\n```", "link": "#what-is-promise-chaining-in-javascript" }, { "title": "What Are the Main Rules of Promise in JavaScript?", "url": "https://www.tiktok.com/@jsmentoring/photo/7449057432086580513", "level": "intermediate", "theme": "Promises, JavaScript", "text": "### What Are the Main Rules of Promise in JavaScript?\n\nThe main rules of Promises in JavaScript are:\n1. A promise can be in one of three states: pending, fulfilled, or rejected.\n2. A promise can only transition from pending to fulfilled or rejected, and cannot change back.\n3. You can attach `.then()` to handle success and `.catch()` for errors.", "link": "#what-are-the-main-rules-of-promise-in-javascript" }, { "title": "What Are the Events Available for Server-Sent Events?", "url": "https://www.tiktok.com/@jsmentoring/photo/7449065499603881248", "level": "intermediate", "theme": "Server-Sent Events, web technologies", "text": "### What Are the Events Available for Server-Sent Events?\n\nServer-Sent Events (SSE) support several event types, including:\n- `message`: The default event for incoming data.\n- `open`: Fired when the connection to the server is established.\n- `error`: Fired when there is an error with the connection.", "link": "#what-are-the-events-available-for-server-sent-events" }, { "title": "How Do You Check Browser Support for Server-Sent Events?", "url": "https://www.tiktok.com/@jsmentoring/photo/7449149383142018336", "level": "basic", "theme": "Server-Sent Events, browser support", "text": "### How Do You Check Browser Support for Server-Sent Events?\n\nTo check if the browser supports Server-Sent Events, you can check for the `EventSource` object:\n\n```javascript\nif (typeof(EventSource) !== 'undefined') {\n // SSE is supported\n} else {\n // SSE is not supported\n}\n```", "link": "#how-do-you-check-browser-support-for-server-sent-events" }, { "title": "What Is `Promise.all` in JavaScript?", "url": "https://www.tiktok.com/@jsmentoring/photo/7449321820743847200", "level": "intermediate", "theme": "Promises, JavaScript, asynchronous programming", "text": "### What Is `Promise.all` in JavaScript?\n\n`Promise.all` is a method that accepts an array of promises and returns a single promise that resolves when all the promises in the array are resolved. If any of the promises reject, the returned promise will reject immediately.\n\n```javascript\nPromise.all([promise1, promise2, promise3])\n .then(results => console.log(results))\n .catch(error => console.error(error));\n```", "link": "#what-is-promise-all-in-javascript" }, { "title": "What Is the Purpose of the `race` Method in Promises?", "url": "https://www.tiktok.com/@jsmentoring/photo/7449363438461144353", "level": "intermediate", "theme": "Promises, JavaScript, asynchronous programming", "text": "### What Is the Purpose of the `race` Method in Promises?\n\nThe `Promise.race()` method returns a promise that resolves or rejects as soon as one of the promises in the iterable resolves or rejects. It is useful when you need to wait for the first promise to settle.\n\n```javascript\nPromise.race([promise1, promise2, promise3])\n .then(result => console.log(result))\n .catch(error => console.error(error));\n```", "link": "#what-is-the-purpose-of-the-race-method-in-promises" }, { "title": "What Is Strict Mode in JavaScript?", "url": "https://www.tiktok.com/@jsmentoring/photo/7449392707455175968", "level": "intermediate", "theme": "JavaScript, strict mode", "text": "### What Is Strict Mode in JavaScript?\n\nStrict mode is a way to opt in to a restricted version of JavaScript. It helps catch common coding mistakes and prevents the use of certain features that can lead to bugs, such as using undeclared variables.\n\n```javascript\n'use strict';\nvar x = 3.14; // Error in strict mode: assignment to undeclared variable\n```", "link": "#what-is-strict-mode-in-javascript" }, { "title": "What Is the Purpose of Double Exclamation in JavaScript?", "url": "https://www.tiktok.com/@jsmentoring/photo/7449429710985022753", "level": "basic", "theme": "JavaScript, type coercion", "text": "### What Is the Purpose of Double Exclamation in JavaScript?\n\nDouble exclamation (`!!`) is used to convert a value into a boolean. The first exclamation negates the value, and the second negates it again, resulting in a boolean representation of the value.\n\n```javascript\nconsole.log(!!'string'); // true\nconsole.log(!!0); // false\n```", "link": "#what-is-the-purpose-of-double-exclamation-in-javascript" }, { "title": "How Do You Declare Strict Mode in JavaScript?", "url": "https://www.tiktok.com/@jsmentoring/photo/7449490448533507361", "level": "basic", "theme": "JavaScript, strict mode", "text": "### How Do You Declare Strict Mode in JavaScript?\n\nTo declare strict mode in JavaScript, simply add `'use strict';` at the beginning of a script or a function.\n\n```javascript\n'use strict';\n// Code here will be executed in strict mode\n```", "link": "#how-do-you-declare-strict-mode-in-javascript" }, { "title": "How Do You Detect Caps Lock Key Turned On or Not?", "url": "https://www.tiktok.com/@jsmentoring/photo/7449671849920761120", "level": "intermediate", "theme": "JavaScript, event handling, keyboard events", "text": "### How Do You Detect Caps Lock Key Turned On or Not?\n\nTo detect whether Caps Lock is on, you can use the `keydown` or `keypress` event and check the `event.getModifierState('CapsLock')` property.\n\n```javascript\ndocument.addEventListener('keydown', function(event) {\n if (event.getModifierState('CapsLock')) {\n console.log('Caps Lock is on');\n }\n});\n```", "link": "#how-do-you-detect-caps-lock-key-turned-on-or-not" }, { "title": "How Do You Access History in JavaScript?", "url": "https://www.tiktok.com/@jsmentoring/photo/7449732288268487969", "level": "basic", "theme": "JavaScript, history API", "text": "### How Do You Access History in JavaScript?\n\nYou can access the browser history using the `window.history` object. This allows you to manipulate the session history (navigate, go back, forward, etc.).\n\n```javascript\nwindow.history.back(); // Go back to the previous page\nwindow.history.forward(); // Go forward in history\n```", "link": "#how-do-you-access-history-in-javascript" }, { "title": "What Is the Difference Between `window` and `document` in JavaScript?", "url": "https://www.tiktok.com/@jsmentoring/photo/7449755076182215968", "level": "basic", "theme": "JavaScript, DOM", "text": "### What Is the Difference Between `window` and `document` in JavaScript?\n\n`window` represents the browser window and is the global object in the browser's JavaScript environment. `document`, on the other hand, represents the HTML document loaded in the browser, allowing interaction with the DOM.\n\n```javascript\nconsole.log(window); // Browser window\nconsole.log(document); // HTML document\n```", "link": "#what-is-the-difference-between-window-and-document-in-javascript" }, { "title": "What Is the Purpose of Double Exclamation in JavaScript?", "url": "https://www.tiktok.com/@jsmentoring/photo/7449813378895203617", "level": "basic", "theme": "JavaScript, type coercion", "text": "### What Is the Purpose of Double Exclamation in JavaScript?\n\nDouble exclamation (`!!`) is used to convert a value to a boolean. The first negation converts it to a boolean, and the second negation reverts it to the correct boolean value.\n\n```javascript\nconsole.log(!!'text'); // true\nconsole.log(!!null); // false\n```", "link": "#what-is-the-purpose-of-double-exclamation-in-javascript" }, { "title": "What Is `eval` in JavaScript?", "url": "https://www.tiktok.com/@jsmentoring/photo/7449833381975559446", "level": "intermediate", "theme": "JavaScript, security", "text": "### What Is `eval` in JavaScript?\n\n`eval()` is a JavaScript function that evaluates a string of JavaScript code. It is generally discouraged due to security risks such as code injection vulnerabilities.\n\n```javascript\neval('console.log(\"Hello, World!\")'); // Logs 'Hello, World!'\n```", "link": "#what-is-eval-in-javascript" }, { "title": "What Is the `null` Value in JavaScript?", "url": "https://www.tiktok.com/@jsmentoring/photo/7449876086793489696", "level": "basic", "theme": "JavaScript, data types", "text": "### What Is the `null` Value in JavaScript?\n\n`null` is a primitive value that represents the intentional absence of any object value. It is used to indicate that a variable is empty or uninitialized.\n\n```javascript\nlet x = null;\nconsole.log(x); // null\n```", "link": "#what-is-the-null-value-in-javascript" }, { "title": "What Is the `undefined` Property in JavaScript?", "url": "https://www.tiktok.com/@jsmentoring/photo/7450179747931278624", "level": "basic", "theme": "JavaScript, data types", "text": "### What Is the `undefined` Property in JavaScript?\n\n`undefined` is a primitive value that is automatically assigned to variables that are declared but not initialized. It represents the absence of a defined value.\n\n```javascript\nlet x;\nconsole.log(x); // undefined\n```", "link": "#what-is-the-undefined-property-in-javascript" }, { "title": "What Is the Purpose of the `delete` Operator in JavaScript?", "url": "https://www.tiktok.com/@jsmentoring/photo/7450258222222560544", "level": "intermediate", "theme": "JavaScript, operators", "text": "### What Is the Purpose of the `delete` Operator in JavaScript?\n\nThe `delete` operator is used to remove a property from an object or an element from an array.\n\n```javascript\nlet obj = { name: 'John', age: 30 };\ndelete obj.age;\nconsole.log(obj); // { name: 'John' }\n```", "link": "#what-is-the-purpose-of-the-delete-operator-in-javascript" }, { "title": "What Is the `typeof` Operator in JavaScript?", "url": "https://www.tiktok.com/@jsmentoring/photo/7450568773712497953", "level": "basic", "theme": "JavaScript, operators", "text": "### What Is the `typeof` Operator in JavaScript?\n\nThe `typeof` operator returns a string indicating the type of the unevaluated operand. It is commonly used to check the type of variables or expressions.\n\n```javascript\nconsole.log(typeof 'Hello'); // string\nconsole.log(typeof 123); // number\n```", "link": "#what-is-the-typeof-operator-in-javascript" }, { "title": "What Is `isNaN` in JavaScript?", "url": "https://www.tiktok.com/@jsmentoring/photo/7450774214459673888", "level": "basic", "theme": "JavaScript, type checking", "text": "### What Is `isNaN` in JavaScript?\n\n`isNaN()` is a function that checks whether a value is NaN (Not-a-Number). It returns `true` if the value is NaN, and `false` otherwise.\n\n```javascript\nconsole.log(isNaN(123)); // false\nconsole.log(isNaN('Hello')); // true\n```", "link": "#what-is-isnan-in-javascript" }, { "title": "What are the differences between undeclared and undefined variables", "url": "https://www.tiktok.com/@jsmentoring/photo/7450925531370884385", "level": "basic", "theme": "JavaScript, variables", "text": "### What are the differences between undeclared and undefined variables?\n\nAn undeclared variable is one that has not been declared using `var`, `let`, or `const`. An undefined variable is one that has been declared but not assigned a value.", "link": "#what-are-the-differences-between-undeclared-and-undefined-variables" }, { "title": "What are global variables", "url": "https://www.tiktok.com/@jsmentoring/photo/7450838618257575201", "level": "basic", "theme": "JavaScript, variables", "text": "### What are global variables?\n\nGlobal variables are variables that are declared outside of any function and are accessible from any part of the code.", "link": "#what-are-global-variables" }, { "title": "What are the problems with global variables", "url": "https://www.tiktok.com/@jsmentoring/photo/7451163740982070561", "level": "intermediate", "theme": "JavaScript, best practices", "text": "### What are the problems with global variables?\n\nGlobal variables can cause issues like name collisions, difficulty in debugging, and unintended side effects. It's recommended to limit the use of global variables.", "link": "#what-are-the-problems-with-global-variables" }, { "title": "What is NaN property", "url": "https://www.tiktok.com/@jsmentoring/photo/7451255958266760480", "level": "basic", "theme": "JavaScript, type checking", "text": "### What is NaN property?\n\n`NaN` (Not-a-Number) is a special value in JavaScript that represents an invalid or undefined numerical result, such as the result of dividing 0 by 0.", "link": "#what-is-nan-property" }, { "title": "What is the purpose of isFinite function", "url": "", "level": "intermediate", "theme": "JavaScript, type checking", "text": "### What is the purpose of isFinite function?\n\n`isFinite()` is used to check if a value is a finite number. It returns `true` if the value is a finite number, and `false` otherwise.", "link": "#what-is-the-purpose-of-isfinite-function" }, { "title": "What is an event flow", "url": "https://www.tiktok.com/@jsmentoring/photo/7451321489682468128", "level": "intermediate", "theme": "JavaScript, events", "text": "### What is an event flow?\n\nEvent flow in JavaScript refers to the order in which events are propagated through the DOM. It consists of three phases: capturing phase, target phase, and bubbling phase.", "link": "#what-is-an-event-flow" }, { "title": "What is event bubbling", "url": "https://www.tiktok.com/@jsmentoring/photo/7451597511862603040", "level": "basic", "theme": "JavaScript, events", "text": "### What is event bubbling?\n\nEvent bubbling is the process where an event triggered on a child element is propagated up to its parent elements. It is the default behavior for most events in JavaScript.", "link": "#what-is-event-bubbling" }, { "link": "#can-i-add-getters-and-setters-using-defineproperty-method", "title": "Can I add getters and setters using defineProperty method", "url": "", "level": "basic", "theme": "JavaScript, objects", "text": "### Can I add getters and setters using defineProperty method?\n\nYes, you can add getters and setters using `Object.defineProperty()`. This allows you to define custom getter and setter methods for specific properties.\n\nExample:\n\n```javascript\nconst person = {};\nObject.defineProperty(person, 'name', {\n get() { return this._name; },\n set(value) { this._name = value.toUpperCase(); }\n});\nperson.name = 'John';\nconsole.log(person.name); // 'JOHN'\n```" }, { "link": "#can-i-avoid-using-postmessages-completely", "title": "Can I avoid using postMessages completely", "url": "", "level": "advanced", "theme": "JavaScript, Security", "text": "### Can I avoid using postMessages completely?\n\nWhile `postMessage` is a useful API for cross-origin communication, alternatives like `localStorage`, `cookies`, or server-side messaging (e.g., WebSockets) can be used depending on the use case. Avoiding `postMessage` may increase security in certain scenarios." }, { "link": "#can-i-redeclare-let-and-const-variables", "title": "Can I redeclare let and const variables", "url": "", "level": "intermediate", "theme": "JavaScript, Variables", "text": "### Can I redeclare `let` and `const` variables?\n\nNo, you cannot redeclare `let` and `con