diff --git a/cli.js b/cli.js index db65f65..ab7c904 100755 --- a/cli.js +++ b/cli.js @@ -10,13 +10,15 @@ const filter = args.top ? 'top' : args.filter || 'all'; const amount = args.top || ''; const level = args.level || ''; const format = args.format || 'text'; +const theme = args.theme || ''; const logHeader = (header) => console.log('\x1b[32m%s\x1b[0m', header); const logDivider = () => console.log('_________________________'); const logExampleParams = () => { console.log("\x1b[32m%s\x1b[0m", "Params example:"); console.log("--top ${amount}"); - console.log("--level ( junior | middle | senior )"); + console.log("--level ( basic | intermediate | advanced )"); + console.log("--theme ( closures | storage | es6 | classes | database ... and other 203 themes)"); console.log("--format ( text | array | json )"); }; @@ -29,10 +31,15 @@ const displayQuestions = (result, format) => { console.log(result); break; default: - result.forEach(({ title, url }) => { + result.forEach(({ title, url, text, theme }) => { console.log(''); logHeader(`Question: ${title}`); - console.info(`Answer: \x1b]8;;${url}\x1b\\${url}\x1b]8;;\x1b\\`); + if (url) { + console.info(`Answer: \x1b]8;;${url}\x1b\\${url}\x1b]8;;\x1b\\`); + } else { + console.info(`Answer: ${text}`); + } + console.info(`Hash: ${theme.split(',').map((data) => ` #${data.trim().toLowerCase()}`)}`); logDivider(); }); } @@ -46,10 +53,11 @@ const main = async () => { if (filter) console.log('Filter -', filter); console.log(''); - const result = await interviewQuestion({ filter, amount, level, format }); + const result = await interviewQuestion({ filter, amount, level, format, theme }); displayQuestions(result, format); console.log(''); + console.log(`Found ${result.length} questions`); logExampleParams(); if (verbose) console.log('Send questions'); diff --git a/index.js b/index.js index 8c128c2..a71332b 100644 --- a/index.js +++ b/index.js @@ -37,7 +37,7 @@ class InterviewQuestion { * @returns {Promise} The filtered list of questions. * @throws {Error} If an invalid level or filter type is provided. */ - async execute(filter = 'all', amount = 0, level = null) { + async execute(filter = 'all', amount = 0, level = null, theme = null) { let filteredData = this.data; // Filter by level if provided @@ -49,6 +49,11 @@ class InterviewQuestion { filteredData = filteredData.filter(item => item.level === level); } + // Filter by level if provided + if (theme) { + filteredData = filteredData.filter(item => item.theme.split(',').map((data) => data.trim().toLowerCase()).includes(theme)); + } + switch (filter) { case 'all': return filteredData; @@ -89,6 +94,6 @@ class InterviewQuestion { */ module.exports = async function (options = {}) { const interviewQuestion = new InterviewQuestion(options); - const { filter = 'all', amount = 0, level = null } = options; - return interviewQuestion.execute(filter, amount, level); + const { filter = 'all', amount = 0, level = null, theme = null } = options; + return interviewQuestion.execute(filter, amount, level, theme); }; \ No newline at end of file diff --git a/package.json b/package.json index 0b09624..b7417bd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "interview-questions", - "version": "1.2.0", + "version": "1.2.3", "main": "index.js", "scripts": { "test": "npx jest ./test/InterviewQuestion.test.js" diff --git a/question.json b/question.json index 80d830f..659b408 100644 --- a/question.json +++ b/question.json @@ -2,181 +2,3647 @@ { "title": "What is IndexedDB", "url": "https://www.tiktok.com/@jsmentoring/photo/7448276165661314336", - "level": "junior" + "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." }, { "title": "What are the options in a cookie", "url": "https://www.tiktok.com/@jsmentoring/photo/7448261980567145761", - "level": "junior" + "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." }, { "title": "Differences between cookie, local storage and session storage", "url": "https://www.tiktok.com/@jsmentoring/photo/7448258461030173985", - "level": "junior" + "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." }, { "title": "How do you delete a cookie", "url": "https://www.tiktok.com/@jsmentoring/photo/7448236859966197025", - "level": "middle" + "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." }, { "title": "What is a post message", "url": "https://www.tiktok.com/@jsmentoring/photo/7448205399074934049", - "level": "middle" + "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." }, { "title": "What are closures", "url": "https://www.tiktok.com/@jsmentoring/photo/7447942704148811041", - "level": "middle" + "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." }, { "title": "What are modules", "url": "https://www.tiktok.com/@jsmentoring/photo/7447936859029654816", - "level": "middle" + "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." }, { "title": "What are classes in ES6", "url": "https://www.tiktok.com/@jsmentoring/photo/7447909741977685280", - "level": "senior" + "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." }, { "title": "Why do you need modules", "url": "https://www.tiktok.com/@jsmentoring/photo/7447895686626020640", - "level": "middle" + "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." }, { "title": "What is Hoisting", "url": "https://www.tiktok.com/@jsmentoring/photo/7447882385946938656", - "level": "junior" + "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." }, { "title": "What is scope in javascript", "url": "https://www.tiktok.com/@jsmentoring/photo/7447877473280265505", - "level": "junior" + "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\\`." }, { "title": "What is a service worker", "url": "https://www.tiktok.com/@jsmentoring/photo/7447871707219594529", - "level": "senior" + "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." }, { "title": "How do you manipulate with DOM element", "url": "https://www.tiktok.com/@jsmentoring/photo/7447865971974475041", - "level": "junior" + "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." }, { "title": "How do you reuse information across service worker restarts", "url": "https://www.tiktok.com/@jsmentoring/photo/7447841580880350497", - "level": "senior" + "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." }, { "title": "What is IndexedDB", "url": "https://www.tiktok.com/@jsmentoring/photo/7447814335323278624", - "level": "senior" + "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." }, { "title": "What is memoization", "url": "https://www.tiktok.com/@jsmentoring/photo/7447658154155871520", - "level": "middle" + "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." }, { - "title": "What is JSON and Its Common Operations", - "url": "https://www.tiktok.com/@jsmentoring/photo/7447560275856870688", - "level": "junior" + "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." }, { "title": "5 Ways to Create Objects in JavaScript", "url": "https://www.tiktok.com/@jsmentoring/photo/7447557117344582944", - "level": "junior" + "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 {}}`" }, { "title": "What is a Prototype Chain in JavaScript?", "url": "https://www.tiktok.com/@jsmentoring/photo/7447534074211601697", - "level": "junior" + "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`." }, { "title": "What is a higher order function", "url": "https://www.tiktok.com/@jsmentoring/photo/7447469800642727200", - "level": "middle" + "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." }, { "title": "What is the currying function", "url": "https://www.tiktok.com/@jsmentoring/photo/7447172210076208417", - "level": "senior" + "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; } }`." }, { "title": "How do you compare Object and Map", "url": "https://www.tiktok.com/@jsmentoring/photo/7447122335863147808", - "level": "senior" + "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." }, { "title": "What is a pure function", "url": "https://www.tiktok.com/@jsmentoring/photo/7447104096424725792", - "level": "senior" + "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." }, { "title": "What is a Prototype Chain in JavaScript?", "url": "https://www.tiktok.com/@jsmentoring/photo/7446735468848270625", - "level": "junior" + "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`." }, { "title": "What is the purpose of the let keyword", "url": "https://www.tiktok.com/@jsmentoring/photo/7446499450626772256", - "level": "junior" + "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." }, { "title": "Arrow func?", "url": "https://www.tiktok.com/@jsmentoring/photo/7446420047448247585", - "level": "junior" + "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." }, { "title": "What is the difference between let and var", "url": "https://www.tiktok.com/@jsmentoring/photo/7446417854699687200", - "level": "junior" + "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)." }, { "title": "What is git bisect command?", "url": "https://www.tiktok.com/@jsmentoring/photo/7446337497484791073", - "level": "senior" + "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." }, { "title": "What are lambda expressions or arrow functions?", "url": "https://www.tiktok.com/@jsmentoring/photo/7446080608989678880", - "level": "junior" + "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." }, { "title": "What is the difference between == and === operators?", "url": "https://www.tiktok.com/@jsmentoring/photo/7446055928723508512", - "level": "junior" + "level": "basic", + "theme": "== vs ===, 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." }, { - "title": "Slide What is the purpose of the array splice method", + "title": "What is the purpose of the array splice method?", "url": "https://www.tiktok.com/@jsmentoring/photo/7446035575565520160", - "level": "junior" + "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." }, { - "title": "What is the difference between slice and splice", + "title": "What is the difference between slice and splice?", "url": "https://www.tiktok.com/@jsmentoring/photo/7446029933446565152", - "level": "junior" + "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." }, { "title": "5 Ways to Create Objects in JavaScript?", "url": "https://www.tiktok.com/@jsmentoring/photo/7445448146685136161", - "level": "junior" + "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 {}}`" }, { "title": "What is git rebase command?", "url": "https://www.tiktok.com/@jsmentoring/photo/7444874869394771232", - "level": "junior" + "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." }, { "title": "What is git reflog command?", "url": "https://www.tiktok.com/@jsmentoring/photo/7444873101717884192", - "level": "junior" + "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." }, { "title": "What is git revert command?", "url": "https://www.tiktok.com/@jsmentoring/photo/7444867368431439136", - "level": "junior" + "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." + }, + { + "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." + }, + { + "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." + }, + { + "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." + }, + { + "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." + }, + { + "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." + }, + { + "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." + }, + { + "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." + }, + { + "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." + }, + { + "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." + }, + { + "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." + }, + { + "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." + }, + { + "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." + }, + { + "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." + }, + { + "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." + }, + { + "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()`." + }, + { + "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." + }, + { + "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```" + }, + { + "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." + }, + { + "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```" + }, + { + "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." + }, + { + "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```" + }, + { + "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." + }, + { + "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." + }, + { + "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```" + }, + { + "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```" + }, + { + "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```" + }, + { + "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```" + }, + { + "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```" + }, + { + "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```" + }, + { + "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```" + }, + { + "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```" + }, + { + "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```" + }, + { + "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```" + }, + { + "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```" + }, + { + "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```" + }, + { + "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```" + }, + { + "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```" + }, + { + "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```" + }, + { + "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```" + }, + { + "title": "What are the differences between undeclared and undefined variables", + "url": "", + "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." + }, + { + "title": "What are global variables", + "url": "", + "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." + }, + { + "title": "What are the problems with global variables", + "url": "", + "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." + }, + { + "title": "What is NaN property", + "url": "", + "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." + }, + { + "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." + }, + { + "title": "What is an event flow", + "url": "", + "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." + }, + { + "title": "What is event bubbling", + "url": "", + "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-capturing", + "title": "What is event capturing", + "url": "", + "level": "intermediate", + "theme": "JavaScript, events", + "text": "### What is event capturing?\n\nEvent capturing is the process where an event is first captured by the outermost element before it reaches the target element. This is the opposite of event bubbling." + }, + { + "link": "#how-do-you-submit-a-form-using-javascript", + "title": "How do you submit a form using JavaScript", + "url": "", + "level": "basic", + "theme": "JavaScript, forms", + "text": "### How do you submit a form using JavaScript?\n\nYou can submit a form in JavaScript using the `submit()` method on the form element, like so:\n\n```javascript\ndocument.getElementById('myForm').submit();\n```" + }, + { + "link": "#how-do-you-find-operating-system-details", + "title": "How do you find operating system details", + "url": "", + "level": "intermediate", + "theme": "JavaScript, environment", + "text": "### How do you find operating system details?\n\nYou can access the operating system details in JavaScript using `navigator.platform` or `navigator.userAgent` to detect the platform or OS of the user." + }, + { + "link": "#what-is-the-difference-between-document-load-and-domcontentloaded-events", + "title": "What is the difference between document load and DOMContentLoaded events", + "url": "", + "level": "intermediate", + "theme": "JavaScript, events", + "text": "### What is the difference between document load and DOMContentLoaded events?\n\nThe `DOMContentLoaded` event fires when the HTML is completely loaded and parsed, while the `load` event waits for all resources (including images and stylesheets) to load." + }, + { + "link": "#what-is-the-difference-between-native-host-and-user-objects", + "title": "What is the difference between native, host and user objects", + "url": "", + "level": "advanced", + "theme": "JavaScript, objects", + "text": "### What is the difference between native, host and user objects?\n\nNative objects are built-in objects like `Object` and `Array`. Host objects are provided by the environment (e.g., browser or Node.js), like `window` or `document`. User objects are those defined by the developer." + }, + { + "link": "#what-are-the-tools-or-techniques-used-for-debugging-javascript-code", + "title": "What are the tools or techniques used for debugging JavaScript code", + "url": "", + "level": "intermediate", + "theme": "JavaScript, debugging", + "text": "### What are the tools or techniques used for debugging JavaScript code?\n\nCommon debugging techniques include using `console.log()`, browser developer tools (F12), breakpoints, and using debuggers like Chrome DevTools or Visual Studio Code." + }, + { + "link": "#what-are-the-pros-and-cons-of-promises-over-callbacks", + "title": "What are the pros and cons of promises over callbacks", + "url": "", + "level": "advanced", + "theme": "JavaScript, promises", + "text": "### What are the pros and cons of promises over callbacks?\n\nPromises provide cleaner, more readable code with `.then()` and `.catch()` methods. They avoid callback hell, but can introduce complexity with chaining and error handling." + }, + { + "link": "#what-is-the-difference-between-an-attribute-and-a-property", + "title": "What is the difference between an attribute and a property", + "url": "", + "level": "basic", + "theme": "JavaScript, DOM", + "text": "### What is the difference between an attribute and a property?\n\nAn attribute is a value set in the HTML (e.g., `src` in an `img` tag), while a property is a value associated with the element in JavaScript (e.g., `element.src`)." + }, + { + "link": "#what-is-same-origin-policy", + "title": "What is same-origin policy", + "url": "", + "level": "intermediate", + "theme": "JavaScript, security", + "text": "### What is same-origin policy?\n\nThe same-origin policy is a security measure that restricts how a document or script loaded from one origin can interact with resources from another origin." + }, + { + "link": "#what-is-the-purpose-of-void-0", + "title": "What is the purpose of void 0", + "url": "", + "level": "advanced", + "theme": "JavaScript, operators", + "text": "### What is the purpose of void 0?\n\n`void 0` is used to return `undefined` in JavaScript. It's a more reliable method than using `undefined` directly, which can be overwritten in some cases." + }, + { + "link": "#is-javascript-a-compiled-or-interpreted-language", + "title": "Is JavaScript a compiled or interpreted language", + "url": "", + "level": "basic", + "theme": "JavaScript, language concepts", + "text": "### Is JavaScript a compiled or interpreted language?\n\nJavaScript is an interpreted language. It is executed line by line by the JavaScript engine in the browser, rather than being compiled beforehand like C or Java." + }, + { + "link": "#is-javascript-a-case-sensitive-language", + "title": "Is JavaScript a case-sensitive language", + "url": "", + "level": "basic", + "theme": "JavaScript, language concepts", + "text": "### Is JavaScript a case-sensitive language?\n\nYes, JavaScript is a case-sensitive language. For example, `variable` and `Variable` would be considered two different identifiers." + }, + { + "link": "#is-there-any-relation-between-java-and-javascript", + "title": "Is there any relation between Java and JavaScript", + "url": "", + "level": "basic", + "theme": "JavaScript, general knowledge", + "text": "### Is there any relation between Java and JavaScript?\n\nDespite the similar names, Java and JavaScript are not directly related. Java is a class-based, object-oriented programming language, while JavaScript is a lightweight, interpreted scripting language primarily used for web development." + }, + { + "link": "#what-are-events", + "title": "What are events", + "url": "", + "level": "basic", + "theme": "JavaScript, events", + "text": "### What are events?\n\nIn JavaScript, events are actions that occur in the browser, such as user interactions like clicks, keypresses, or page loading. JavaScript allows you to handle these events using event listeners." + }, + { + "link": "#who-created-javascript", + "title": "Who created JavaScript", + "url": "", + "level": "basic", + "theme": "JavaScript, history", + "text": "### Who created JavaScript?\n\nJavaScript was created by Brendan Eich in 1995 while working at Netscape Communications Corporation. It was originally called Mocha, then renamed to LiveScript, and finally to JavaScript." + }, + { + "link": "#what-is-the-use-of-preventdefault-method", + "title": "What is the use of preventDefault method", + "url": "", + "level": "basic", + "theme": "JavaScript, events", + "text": "### What is the use of preventDefault method?\n\nThe `preventDefault()` method is used to cancel the default behavior of an event. For example, you can prevent the form from submitting or a link from navigating to a new page." + }, + { + "link": "#what-is-the-use-of-stoppropagation-method", + "title": "What is the use of stopPropagation method", + "url": "", + "level": "basic", + "theme": "JavaScript, events", + "text": "### What is the use of stopPropagation method?\n\nThe `stopPropagation()` method prevents the event from propagating (bubbling) up or down the DOM tree. This is useful for preventing parent elements from handling events triggered by child elements." + }, + { + "link": "#what-are-the-steps-involved-in-return-false-usage", + "title": "What are the steps involved in return false usage", + "url": "", + "level": "intermediate", + "theme": "JavaScript, events", + "text": "### What are the steps involved in return false usage?\n\n`return false` is used to prevent both the default behavior and the event propagation in one step. It can be used in an event handler to stop the event from bubbling and cancel the default action." + }, + { + "link": "#what-is-bom", + "title": "What is BOM", + "url": "", + "level": "intermediate", + "theme": "JavaScript, browser", + "text": "### What is BOM?\n\nThe Browser Object Model (BOM) allows JavaScript to interact with the browser outside of the DOM. It includes objects like `window`, `navigator`, `screen`, and `location`, enabling you to control browser-related functions." + }, + { + "link": "#what-is-the-use-of-settimeout", + "title": "What is the use of setTimeout", + "url": "", + "level": "basic", + "theme": "JavaScript, timing", + "text": "### What is the use of setTimeout?\n\nThe `setTimeout()` method is used to execute a function or code snippet after a specified delay in milliseconds. It's useful for delaying the execution of a task.\n\n```javascript\nsetTimeout(function(){ alert('Hello!'); }, 2000);\n```" + }, + { + "link": "#what-is-the-use-of-setinterval", + "title": "What is the use of setInterval", + "url": "", + "level": "basic", + "theme": "JavaScript, timing", + "text": "### What is the use of setInterval?\n\nThe `setInterval()` method calls a function or code snippet repeatedly, with a fixed time delay between each call. It's useful for creating repeating actions.\n\n```javascript\nsetInterval(function(){ console.log('Hello!'); }, 1000);\n```" + }, + { + "link": "#why-is-javascript-treated-as-single-threaded", + "title": "Why is JavaScript treated as Single threaded", + "url": "", + "level": "intermediate", + "theme": "JavaScript, concurrency", + "text": "### Why is JavaScript treated as Single threaded?\n\nJavaScript is single-threaded because it executes code in one thread, meaning only one operation can be performed at a time. This simplifies development, but asynchronous programming techniques like callbacks, promises, and async/await are used to handle concurrency." + }, + { + "link": "#what-is-an-event-delegation", + "title": "What is an event delegation", + "url": "", + "level": "intermediate", + "theme": "JavaScript, events", + "text": "### What is an event delegation?\n\nEvent delegation is a technique where you attach a single event listener to a parent element, which handles events for its child elements. This is more efficient than adding event listeners to each child element individually." + }, + { + "link": "#what-is-ecmascript", + "title": "What is ECMAScript", + "url": "", + "level": "basic", + "theme": "JavaScript, standards", + "text": "### What is ECMAScript?\n\nECMAScript is the standard specification that JavaScript is based on. It defines the core features and behavior of JavaScript, and different versions of ECMAScript introduce new features to the language." + }, + { + "link": "#what-is-json", + "title": "What is JSON", + "url": "", + "level": "basic", + "theme": "JavaScript, data formats", + "text": "### What is JSON?\n\nJSON (JavaScript Object Notation) is a lightweight data-interchange format that is easy for humans to read and write, and easy for machines to parse and generate. It is often used to exchange data between a client and server." + }, + { + "link": "#what-are-the-syntax-rules-of-json", + "title": "What are the syntax rules of JSON", + "url": "", + "level": "basic", + "theme": "JavaScript, data formats", + "text": "### What are the syntax rules of JSON?\n\nJSON syntax rules include using double quotes for keys and string values, no trailing commas, and values can be strings, numbers, objects, arrays, true, false, or null." + }, + { + "link": "#what-is-the-purpose-json-stringify", + "title": "What is the purpose JSON stringify", + "url": "", + "level": "basic", + "theme": "JavaScript, data formats", + "text": "### What is the purpose of JSON.stringify?\n\n`JSON.stringify()` is used to convert a JavaScript object into a JSON string, which can be sent to a server or stored for later use." + }, + { + "link": "#how-do-you-parse-json-string", + "title": "How do you parse JSON string", + "url": "", + "level": "basic", + "theme": "JavaScript, data formats", + "text": "### How do you parse a JSON string?\n\nYou can parse a JSON string using the `JSON.parse()` method, which converts the JSON string into a JavaScript object.\n\n```javascript\nconst obj = JSON.parse('{\"name\":\"John\"}');\nconsole.log(obj.name); // John\n```" + }, + { + "link": "#why-do-you-need-json", + "title": "Why do you need JSON", + "url": "", + "level": "basic", + "theme": "JavaScript, data formats", + "text": "### Why do you need JSON?\n\nJSON is used for exchanging data between a client and server, especially in web applications. It is lightweight, easy to parse, and widely supported by many programming languages." + }, + { + "link": "#what-are-pwas", + "title": "What are PWAs", + "url": "", + "level": "basic", + "theme": "JavaScript, web technologies", + "text": "### What are PWAs?\n\nProgressive Web Apps (PWAs) are web applications that use modern web capabilities to deliver an app-like experience to users. They are reliable, fast, and engaging, offering offline capabilities, push notifications, and the ability to be installed on the user's device." + }, + { + "link": "#what-is-the-purpose-of-cleartimeout-method", + "title": "What is the purpose of clearTimeout method", + "url": "", + "level": "basic", + "theme": "JavaScript, timing", + "text": "### What is the purpose of clearTimeout method?\n\nThe `clearTimeout()` method is used to cancel a timeout that was previously established by calling `setTimeout()`. It prevents the function from being executed after the specified delay." + }, + { + "link": "#what-is-the-purpose-of-clearinterval-method", + "title": "What is the purpose of clearInterval method", + "url": "", + "level": "basic", + "theme": "JavaScript, timing", + "text": "### What is the purpose of clearInterval method?\n\nThe `clearInterval()` method is used to cancel a timeout set by `setInterval()`. It stops the function from being called repeatedly after the specified interval." + }, + { + "link": "#how-do-you-redirect-new-page-in-javascript", + "title": "How do you redirect new page in javascript", + "url": "", + "level": "basic", + "theme": "JavaScript, web navigation", + "text": "### How do you redirect to a new page in JavaScript?\n\nTo redirect to a new page in JavaScript, you can use `window.location.href` or `window.location.assign()`. Both methods will navigate the browser to the specified URL.\n\n```javascript\nwindow.location.href = 'https://example.com';\n```" + }, + { + "link": "#how-do-you-check-whether-a-string-contains-a-substring", + "title": "How do you check whether a string contains a substring", + "url": "", + "level": "basic", + "theme": "JavaScript, string manipulation", + "text": "### How do you check whether a string contains a substring?\n\nTo check if a string contains a substring, you can use the `includes()` method, which returns `true` if the substring is found.\n\n```javascript\nconst str = 'Hello World';\nconsole.log(str.includes('World')); // true\n```" + }, + { + "link": "#how-do-you-validate-an-email-in-javascript", + "title": "How do you validate an email in javascript", + "url": "", + "level": "basic", + "theme": "JavaScript, validation", + "text": "### How do you validate an email in JavaScript?\n\nTo validate an email in JavaScript, you can use a regular expression. A common pattern for basic email validation looks like this:\n\n```javascript\nconst email = 'test@example.com';\nconst regex = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,4}$/;\nconsole.log(regex.test(email)); // true\n```" + }, + { + "link": "#how-do-you-get-the-current-url-with-javascript", + "title": "How do you get the current url with javascript", + "url": "", + "level": "basic", + "theme": "JavaScript, web navigation", + "text": "### How do you get the current URL with JavaScript?\n\nYou can get the current URL of the page using `window.location.href`.\n\n```javascript\nconsole.log(window.location.href); // Outputs the current URL\n```" + }, + { + "link": "#what-are-the-various-url-properties-of-location-object", + "title": "What are the various URL properties of location object", + "url": "", + "level": "basic", + "theme": "JavaScript, web navigation", + "text": "### What are the various URL properties of the location object?\n\nThe `location` object has several properties, including `href`, `protocol`, `hostname`, `pathname`, `search`, and `hash`, which allow you to get and manipulate different parts of the current URL." + }, + { + "link": "#how-do-get-query-string-values-in-javascript", + "title": "How do get query string values in javascript", + "url": "", + "level": "basic", + "theme": "JavaScript, web navigation", + "text": "### How do you get query string values in JavaScript?\n\nTo get query string values, you can use the `URLSearchParams` object.\n\n```javascript\nconst params = new URLSearchParams(window.location.search);\nconsole.log(params.get('id')); // Gets the value of the 'id' parameter\n```" + }, + { + "link": "#how-do-you-check-if-a-key-exists-in-an-object", + "title": "How do you check if a key exists in an object", + "url": "", + "level": "basic", + "theme": "JavaScript, objects", + "text": "### How do you check if a key exists in an object?\n\nYou can check if a key exists in an object using the `in` operator or the `hasOwnProperty()` method.\n\n```javascript\nconst obj = {name: 'John'};\nconsole.log('name' in obj); // true\nconsole.log(obj.hasOwnProperty('name')); // true\n```" + }, + { + "link": "#how-do-you-loop-through-or-enumerate-javascript-object", + "title": "How do you loop through or enumerate javascript object", + "url": "", + "level": "basic", + "theme": "JavaScript, objects", + "text": "### How do you loop through or enumerate a JavaScript object?\n\nYou can loop through an object using `for...in` or `Object.keys()` combined with `forEach()`.\n\n```javascript\nconst obj = {name: 'John', age: 30};\nfor (let key in obj) {\n console.log(key, obj[key]);\n}\n```" + }, + { + "link": "#how-do-you-test-for-an-empty-object", + "title": "How do you test for an empty object", + "url": "", + "level": "basic", + "theme": "JavaScript, objects", + "text": "### How do you test for an empty object?\n\nTo check if an object is empty, you can use `Object.keys()` and check if the length is zero.\n\n```javascript\nconst obj = {};\nconsole.log(Object.keys(obj).length === 0); // true\n```" + }, + { + "link": "#what-is-an-arguments-object", + "title": "What is an arguments object", + "url": "", + "level": "basic", + "theme": "JavaScript, functions", + "text": "### What is an arguments object?\n\nThe `arguments` object is an array-like object available within all non-arrow functions. It contains the values of all arguments passed to the function.\n\n```javascript\nfunction test() {\n console.log(arguments);\n}\ntest(1, 2, 3); // { '0': 1, '1': 2, '2': 3 }\n```" + }, + { + "link": "#how-do-you-make-first-letter-of-the-string-in-an-uppercase", + "title": "How do you make first letter of the string in an uppercase", + "url": "", + "level": "basic", + "theme": "JavaScript, string manipulation", + "text": "### How do you make the first letter of the string uppercase?\n\nTo make the first letter uppercase, you can use the `charAt()` method and `toUpperCase()` along with `slice()`.\n\n```javascript\nconst str = 'hello';\nconst result = str.charAt(0).toUpperCase() + str.slice(1);\nconsole.log(result); // 'Hello'\n```" + }, + { + "link": "#what-are-the-pros-and-cons-of-for-loops", + "title": "What are the pros and cons of for loops", + "url": "", + "level": "basic", + "theme": "JavaScript, loops", + "text": "### What are the pros and cons of for loops?\n\n**Pros**: `for` loops are simple, efficient, and widely supported. They provide complete control over the iteration.\n\n**Cons**: Can be error-prone, especially with complex conditions or manual index management." + }, + { + "link": "#how-do-you-display-the-current-date-in-javascript", + "title": "How do you display the current date in javascript", + "url": "", + "level": "basic", + "theme": "JavaScript, date and time", + "text": "### How do you display the current date in JavaScript?\n\nTo display the current date, you can use the `Date` object.\n\n```javascript\nconst currentDate = new Date();\nconsole.log(currentDate); // Displays the current date and time\n```" + }, + { + "link": "#how-do-you-compare-two-date-objects", + "title": "How do you compare two date objects", + "url": "", + "level": "basic", + "theme": "JavaScript, date and time", + "text": "### How do you compare two date objects?\n\nTo compare two date objects, you can use `getTime()` method, which returns the time value in milliseconds.\n\n```javascript\nconst date1 = new Date('2024-12-01');\nconst date2 = new Date('2024-12-01');\nconsole.log(date1.getTime() === date2.getTime()); // true\n```" + }, + { + "link": "#how-do-you-check-if-a-string-starts-with-another-string", + "title": "How do you check if a string starts with another string", + "url": "", + "level": "basic", + "theme": "JavaScript, string manipulation", + "text": "### How do you check if a string starts with another string?\n\nYou can use the `startsWith()` method to check if a string starts with a given substring.\n\n```javascript\nconst str = 'Hello World';\nconsole.log(str.startsWith('Hello')); // true\n```" + }, + { + "link": "#how-do-you-trim-a-string-in-javascript", + "title": "How do you trim a string in javascript", + "url": "", + "level": "basic", + "theme": "JavaScript, string manipulation", + "text": "### How do you trim a string in JavaScript?\n\nTo remove whitespace from both ends of a string, use the `trim()` method.\n\n```javascript\nconst str = ' Hello World ';\nconsole.log(str.trim()); // 'Hello World'\n```" + }, + { + "link": "#how-do-you-add-a-key-value-pair-in-javascript", + "title": "How do you add a key value pair in javascript", + "url": "", + "level": "basic", + "theme": "JavaScript, objects", + "text": "### How do you add a key-value pair in JavaScript?\n\nTo add a key-value pair to an object, you can simply assign a value to a new key.\n\n```javascript\nconst obj = {};\nobj.name = 'John';\nconsole.log(obj); // { name: 'John' }\n```" + }, + { + "link": "#is-the----notation-represents-a-special-operator", + "title": "Is the !-- notation represents a special operator", + "url": "", + "level": "basic", + "theme": "JavaScript, operators", + "text": "### Is the `!--` notation represents a special operator?\n\nThe `!--` notation is not a special operator in JavaScript. It is often a typo or part of HTML comments (``). In JavaScript, `!` is the logical NOT operator, and `--` is the decrement operator." + }, + { + "link": "#how-do-you-assign-default-values-to-variables", + "title": "How do you assign default values to variables", + "url": "", + "level": "basic", + "theme": "JavaScript, variables", + "text": "### How do you assign default values to variables?\n\nYou can assign default values to variables using the `||` operator or by using destructuring assignment.\n\n```javascript\nconst name = userInput || 'Default Name';\n```" + }, + { + "link": "#how-do-you-define-multiline-strings", + "title": "How do you define multiline strings", + "url": "", + "level": "basic", + "theme": "JavaScript, string manipulation", + "text": "### How do you define multiline strings?\n\nYou can define multiline strings using template literals (backticks).\n\n```javascript\nconst str = `Hello\nWorld`;\nconsole.log(str); // 'Hello\nWorld'\n```" + }, + { + "link": "#what-is-an-app-shell-model", + "title": "What is an app shell model", + "url": "", + "level": "basic", + "theme": "JavaScript, web development", + "text": "### What is an app shell model?\n\nThe app shell model is a design approach where the static structure of a web app (such as HTML, CSS, and JavaScript) is cached and loaded first, followed by dynamic content. This approach is used in Progressive Web Apps (PWAs)." + }, + { + "link": "#can-we-define-properties-for-functions", + "title": "Can we define properties for functions", + "url": "", + "level": "basic", + "theme": "JavaScript, functions", + "text": "### Can we define properties for functions?\n\nYes, functions in JavaScript are objects, so you can define properties for them.\n\n```javascript\nfunction myFunc() {}\nmyFunc.property = 'value';\nconsole.log(myFunc.property); // 'value'\n```" + }, + { + "link": "#what-is-the-way-to-find-the-number-of-parameters-expected-by-a-function", + "title": "What is the way to find the number of parameters expected by a function", + "url": "", + "level": "basic", + "theme": "JavaScript, functions", + "text": "### What is the way to find the number of parameters expected by a function?\n\nYou can use the `length` property of a function to find the number of parameters it expects.\n\n```javascript\nfunction test(a, b, c) {}\nconsole.log(test.length); // 3\n```" + }, + { + "link": "#what-is-a-polyfill", + "title": "What is a polyfill", + "url": "", + "level": "basic", + "theme": "JavaScript, web development", + "text": "### What is a polyfill?\n\nA polyfill is a piece of code that implements a feature in a browser that does not support it natively. It ensures compatibility with older browsers.\n\nExample: A polyfill for `Array.prototype.includes`:\n\n```javascript\nif (!Array.prototype.includes) {\n Array.prototype.includes = function(element) {\n return this.indexOf(element) !== -1;\n };\n}\n```" + }, + { + "link": "#what-are-break-and-continue-statements", + "title": "What are break and continue statements", + "url": "", + "level": "basic", + "theme": "JavaScript, control flow", + "text": "### What are break and continue statements?\n\n- `break` is used to exit a loop prematurely.\n- `continue` is used to skip the current iteration and proceed to the next iteration of the loop.\n\nExample:\n\n```javascript\nfor (let i = 0; i < 5; i++) {\n if (i === 3) break;\n console.log(i); // 0, 1, 2\n}\n```" + }, + { + "link": "#what-are-js-labels", + "title": "What are JS labels", + "url": "", + "level": "basic", + "theme": "JavaScript, control flow", + "text": "### What are JS labels?\n\nA label in JavaScript is used to identify a loop or a block of code, allowing you to use `break` or `continue` to exit or skip to the labeled code.\n\nExample:\n\n```javascript\nouterLoop: for (let i = 0; i < 5; i++) {\n for (let j = 0; j < 5; j++) {\n if (i === 2 && j === 2) break outerLoop;\n }\n}\n```" + }, + { + "link": "#what-are-the-benefits-of-keeping-declarations-at-the-top", + "title": "What are the benefits of keeping declarations at the top", + "url": "", + "level": "basic", + "theme": "JavaScript, best practices", + "text": "### What are the benefits of keeping declarations at the top?\n\nDeclaring variables at the top of the scope helps avoid confusion and ensures that the variables are hoisted properly. This practice can also improve code readability and debugging." + }, + { + "link": "#what-are-the-benefits-of-initializing-variables", + "title": "What are the benefits of initializing variables", + "url": "", + "level": "basic", + "theme": "JavaScript, best practices", + "text": "### What are the benefits of initializing variables?\n\nInitializing variables ensures that they have a defined value when accessed, which helps avoid bugs caused by undefined variables and improves code reliability." + }, + { + "link": "#what-are-the-recommendations-to-create-new-object", + "title": "What are the recommendations to create new object", + "url": "", + "level": "basic", + "theme": "JavaScript, objects", + "text": "### What are the recommendations to create new objects?\n\nUse object literals `{}` or `Object.create()` to create objects in JavaScript. The object literal syntax is simple and efficient for most use cases.\n\nExample:\n\n```javascript\nconst obj = { name: 'John', age: 30 };\n```" + }, + { + "link": "#how-do-you-define-json-arrays", + "title": "How do you define JSON arrays", + "url": "", + "level": "basic", + "theme": "JavaScript, JSON", + "text": "### How do you define JSON arrays?\n\nJSON arrays are defined in the same way as JavaScript arrays, but they must be in a string format. They can hold any type of data (strings, numbers, objects, etc.).\n\nExample:\n\n```json\n[\"apple\", \"banana\", \"cherry\"]\n```" + }, + { + "link": "#how-do-you-generate-random-integers", + "title": "How do you generate random integers", + "url": "", + "level": "basic", + "theme": "JavaScript, math", + "text": "### How do you generate random integers?\n\nYou can use `Math.random()` and `Math.floor()` to generate random integers.\n\nExample:\n\n```javascript\nconst randomInt = Math.floor(Math.random() * 10); // Generates a random integer between 0 and 9\nconsole.log(randomInt);\n```" + }, + { + "link": "#can-you-write-a-random-integers-function-to-print-integers-within-a-range", + "title": "Can you write a random integers function to print integers within a range", + "url": "", + "level": "basic", + "theme": "JavaScript, math", + "text": "### Can you write a random integers function to print integers within a range?\n\nYou can create a function that generates random integers within a specified range.\n\nExample:\n\n```javascript\nfunction getRandomInt(min, max) {\n return Math.floor(Math.random() * (max - min + 1)) + min;\n}\nconsole.log(getRandomInt(1, 100)); // Generates a random integer between 1 and 100\n```" + }, + { + "link": "#what-is-tree-shaking", + "title": "What is tree shaking", + "url": "", + "level": "basic", + "theme": "JavaScript, optimization", + "text": "### What is tree shaking?\n\nTree shaking is a process used in JavaScript bundlers (like Webpack) to remove unused code from the final bundle. It helps reduce the size of the final output and improves performance." + }, + { + "link": "#what-is-the-need-of-tree-shaking", + "title": "What is the need of tree shaking", + "url": "", + "level": "basic", + "theme": "JavaScript, optimization", + "text": "### What is the need of tree shaking?\n\nTree shaking is necessary to eliminate dead code, improve the performance of web applications, and reduce the size of JavaScript bundles, leading to faster load times and better user experiences." + }, + { + "link": "#is-it-recommended-to-use-eval", + "title": "Is it recommended to use eval", + "url": "", + "level": "basic", + "theme": "JavaScript, security", + "text": "### Is it recommended to use eval?\n\nIt is generally not recommended to use `eval()` in JavaScript due to security risks and performance concerns. `eval()` executes code passed as a string, which can be exploited by attackers." + }, + { + "link": "#what-is-a-regular-expression", + "title": "What is a Regular Expression", + "url": "", + "level": "basic", + "theme": "JavaScript, regular expressions", + "text": "### What is a Regular Expression?\n\nA regular expression (regex) is a pattern used to match character combinations in strings. It is commonly used for validating input or searching for patterns.\n\nExample:\n\n```javascript\nconst regex = /\\d+/;\nconsole.log(regex.test('123')); // true\n```" + }, + { + "link": "#what-are-the-string-methods-that-accept-regular-expression", + "title": "What are the string methods that accept Regular expression", + "url": "", + "level": "basic", + "theme": "JavaScript, regular expressions", + "text": "### What are the string methods that accept Regular expression?\n\nString methods like `match()`, `replace()`, `search()`, and `split()` accept regular expressions to perform pattern matching and replacement in strings." + }, + { + "link": "#what-are-modifiers-in-regular-expression", + "title": "What are modifiers in regular expression", + "url": "", + "level": "basic", + "theme": "JavaScript, regular expressions", + "text": "### What are modifiers in regular expression?\n\nModifiers are flags that alter the behavior of regular expressions. Common modifiers include:\n\n- `g` (global): Matches all occurrences.\n- `i` (ignore case): Ignores case when matching.\n- `m` (multiline): Treats beginning and end characters (^ and $) as working across multiple lines." + }, + { + "link": "#what-are-regular-expression-patterns", + "title": "What are regular expression patterns", + "url": "", + "level": "basic", + "theme": "JavaScript, regular expressions", + "text": "### What are regular expression patterns?\n\nRegular expression patterns are sequences of characters that form search patterns. They are used to match strings based on specific rules. Patterns can include literals, special characters, and character classes.\n\nExample:\n\n```javascript\nconst regex = /\\d+/; // Matches one or more digits\nconsole.log('123abc'.match(regex)); // ['123']\n```" + }, + { + "link": "#what-is-a-regexp-object", + "title": "What is a RegExp object", + "url": "", + "level": "basic", + "theme": "JavaScript, regular expressions", + "text": "### What is a RegExp object?\n\nA `RegExp` object in JavaScript is used to work with regular expressions. It provides methods like `exec()` and `test()` to search for patterns in strings.\n\nExample:\n\n```javascript\nconst regex = new RegExp('\\d+');\nconsole.log(regex.test('123')); // true\n```" + }, + { + "link": "#how-do-you-search-a-string-for-a-pattern", + "title": "How do you search a string for a pattern", + "url": "", + "level": "basic", + "theme": "JavaScript, regular expressions", + "text": "### How do you search a string for a pattern?\n\nYou can use the `test()` method of the `RegExp` object to search for a pattern in a string.\n\nExample:\n\n```javascript\nconst regex = /\\d+/;\nconsole.log(regex.test('abc123')); // true\n```" + }, + { + "link": "#what-is-the-purpose-of-exec-method", + "title": "What is the purpose of exec method", + "url": "", + "level": "basic", + "theme": "JavaScript, regular expressions", + "text": "### What is the purpose of exec method?\n\nThe `exec()` method executes a search for a match in a string. It returns an array of matches, or `null` if no match is found.\n\nExample:\n\n```javascript\nconst regex = /\\d+/;\nconsole.log(regex.exec('abc123')); // ['123']\n```" + }, + { + "link": "#how-do-you-change-the-style-of-a-html-element", + "title": "How do you change the style of a HTML element", + "url": "", + "level": "basic", + "theme": "JavaScript, DOM manipulation", + "text": "### How do you change the style of a HTML element?\n\nYou can change the style of an HTML element by accessing its `style` property in JavaScript.\n\nExample:\n\n```javascript\nconst element = document.getElementById('myElement');\nelement.style.backgroundColor = 'blue';\n```" + }, + { + "link": "#what-would-be-the-result-of-123", + "title": "What would be the result of 1+2+'3'", + "url": "", + "level": "basic", + "theme": "JavaScript, type coercion", + "text": "### What would be the result of 1+2+'3'?\n\nIn JavaScript, `1 + 2 + '3'` results in `'33'` because the `+` operator first adds the numbers (`1 + 2 = 3`) and then concatenates the result with the string `'3'`.\n\nExample:\n\n```javascript\nconsole.log(1 + 2 + '3'); // '33'\n```" + }, + { + "link": "#what-is-a-debugger-statement", + "title": "What is a debugger statement", + "url": "", + "level": "basic", + "theme": "JavaScript, debugging", + "text": "### What is a debugger statement?\n\nThe `debugger` statement is used to stop the execution of JavaScript and invoke the debugging functionality of the browser. It can be used to set breakpoints during development.\n\nExample:\n\n```javascript\ndebugger;\nconsole.log('This will pause execution');\n```" + }, + { + "link": "#what-is-the-purpose-of-breakpoints-in-debugging", + "title": "What is the purpose of breakpoints in debugging", + "url": "", + "level": "basic", + "theme": "JavaScript, debugging", + "text": "### What is the purpose of breakpoints in debugging?\n\nBreakpoints are used in debugging to pause the execution of JavaScript at a specific point. This allows you to inspect variables, control flow, and diagnose issues.\n\nExample: You can set a breakpoint in the browser's developer tools to pause execution at a specific line." + }, + { + "link": "#can-i-use-reserved-words-as-identifiers", + "title": "Can I use reserved words as identifiers", + "url": "", + "level": "basic", + "theme": "JavaScript, syntax", + "text": "### Can I use reserved words as identifiers?\n\nNo, you cannot use reserved words (such as `let`, `class`, `function`, etc.) as identifiers (variable names, function names, etc.) in JavaScript.\n\nExample:\n\n```javascript\nlet let = 5; // SyntaxError: Unexpected token 'let'\n```" + }, + { + "link": "#how-do-you-detect-a-mobile-browser", + "title": "How do you detect a mobile browser", + "url": "", + "level": "basic", + "theme": "JavaScript, mobile detection", + "text": "### How do you detect a mobile browser?\n\nYou can detect a mobile browser by checking the `navigator.userAgent` string for keywords like 'mobile', 'Android', or 'iPhone'.\n\nExample:\n\n```javascript\nif (/Mobi/.test(navigator.userAgent)) {\n console.log('Mobile browser detected');\n}\n```" + }, + { + "link": "#how-do-you-detect-a-mobile-browser-without-regexp", + "title": "How do you detect a mobile browser without regexp", + "url": "", + "level": "basic", + "theme": "JavaScript, mobile detection", + "text": "### How do you detect a mobile browser without regexp?\n\nYou can detect a mobile browser without using regular expressions by checking for specific properties in `navigator` or `window` objects, such as `navigator.platform` or `window.innerWidth`.\n\nExample:\n\n```javascript\nif (navigator.platform.indexOf('iPhone') !== -1) {\n console.log('iPhone detected');\n}\n```" + }, + { + "link": "#how-do-you-get-the-image-width-and-height-using-js", + "title": "How do you get the image width and height using JS", + "url": "", + "level": "basic", + "theme": "JavaScript, DOM manipulation", + "text": "### How do you get the image width and height using JS?\n\nYou can get the width and height of an image element using the `width` and `height` properties.\n\nExample:\n\n```javascript\nconst img = document.getElementById('myImage');\nconsole.log(img.width, img.height);\n```" + }, + { + "link": "#how-do-you-make-synchronous-http-request", + "title": "How do you make synchronous HTTP request", + "url": "", + "level": "basic", + "theme": "JavaScript, HTTP requests", + "text": "### How do you make synchronous HTTP request?\n\nYou can make a synchronous HTTP request using `XMLHttpRequest` with `open()` and `send()` methods, and setting the `async` parameter to `false`.\n\nExample:\n\n```javascript\nconst xhr = new XMLHttpRequest();\nxhr.open('GET', 'https://api.example.com', false);\nxhr.send();\nconsole.log(xhr.responseText);\n```" + }, + { + "link": "#how-do-you-make-asynchronous-http-request", + "title": "How do you make asynchronous HTTP request", + "url": "", + "level": "basic", + "theme": "JavaScript, HTTP requests", + "text": "### How do you make asynchronous HTTP request?\n\nYou can make an asynchronous HTTP request using `XMLHttpRequest` with `open()` and `send()` methods, and setting the `async` parameter to `true`.\n\nExample:\n\n```javascript\nconst xhr = new XMLHttpRequest();\nxhr.open('GET', 'https://api.example.com', true);\nxhr.send();\nxhr.onload = function() {\n console.log(xhr.responseText);\n};\n```" + }, + { + "link": "#how-do-you-convert-date-to-another-timezone-in-javascript", + "title": "How do you convert date to another timezone in javascript", + "url": "", + "level": "basic", + "theme": "JavaScript, date manipulation", + "text": "### How do you convert date to another timezone in javascript?\n\nYou can use libraries like `moment.js` or the `Intl.DateTimeFormat` API to convert dates to different time zones.\n\nExample with `Intl.DateTimeFormat`:\n\n```javascript\nconst date = new Date();\nconst formatter = new Intl.DateTimeFormat('en-US', {\n timeZone: 'America/New_York',\n hour: 'numeric',\n minute: 'numeric'\n});\nconsole.log(formatter.format(date));\n```" + }, + { + "link": "#what-are-the-properties-used-to-get-size-of-window", + "title": "What are the properties used to get size of window", + "url": "", + "level": "basic", + "theme": "JavaScript, window properties", + "text": "### What are the properties used to get size of window?\n\nTo get the size of the window, you can use `window.innerWidth` and `window.innerHeight` for the dimensions of the viewport.\n\nExample:\n\n```javascript\nconsole.log(window.innerWidth, window.innerHeight);\n```" + }, + { + "link": "#what-is-a-conditional-operator-in-javascript", + "title": "What is a conditional operator in javascript", + "url": "", + "level": "basic", + "theme": "JavaScript, operators", + "text": "### What is a conditional operator in javascript?\n\nThe conditional (ternary) operator is a shorthand for an `if-else` statement. It evaluates a condition and returns one of two values based on whether the condition is true or false.\n\nExample:\n\n```javascript\nconst result = (age >= 18) ? 'Adult' : 'Minor';\n```" + }, + { + "link": "#can-you-apply-chaining-on-conditional-operator", + "title": "Can you apply chaining on conditional operator", + "url": "", + "level": "basic", + "theme": "JavaScript, operators", + "text": "### Can you apply chaining on conditional operator?\n\nYes, you can chain multiple conditional operators together to evaluate multiple conditions in a single expression.\n\nExample:\n\n```javascript\nconst result = (age >= 18) ? 'Adult' : (age >= 13) ? 'Teen' : 'Child';\n```" + }, + { + "link": "#what-are-the-ways-to-execute-javascript-after-page-load", + "title": "What are the ways to execute javascript after page load", + "url": "", + "level": "basic", + "theme": "JavaScript, page load", + "text": "### What are the ways to execute JavaScript after page load?\n\nYou can execute JavaScript after the page loads using the `window.onload` event or by using `DOMContentLoaded` event. Additionally, you can use `setTimeout()` or `setInterval()` to delay the execution.\n\nExample:\n\n```javascript\nwindow.onload = function() {\n console.log('Page loaded');\n};\n```" + }, + { + "link": "#what-is-the-difference-between-proto-and-prototype", + "title": "What is the difference between proto and prototype", + "url": "", + "level": "basic", + "theme": "JavaScript, objects", + "text": "### What is the difference between proto and prototype?\n\n`proto` is an internal property (or link) to the object's prototype, while `prototype` is a property of functions (used to create new objects) that defines methods and properties shared by all instances.\n\nExample:\n\n```javascript\nfunction Person(name) {\n this.name = name;\n}\nPerson.prototype.greet = function() {\n console.log('Hello ' + this.name);\n};\n```" + }, + { + "link": "#can-you-give-an-example-of-when-you-really-need-a-semicolon", + "title": "Can you give an example of when you really need a semicolon", + "url": "", + "level": "basic", + "theme": "JavaScript, syntax", + "text": "### Can you give an example of when you really need a semicolon?\n\nSemicolons are generally optional in JavaScript, but there are situations where they are required. For example, when returning an object from a function on the same line.\n\nExample:\n\n```javascript\nreturn { key: 'value' }; // Requires semicolon\n```" + }, + { + "link": "#what-is-a-freeze-method", + "title": "What is a freeze method", + "url": "", + "level": "basic", + "theme": "JavaScript, objects", + "text": "### What is a freeze method?\n\nThe `Object.freeze()` method freezes an object, preventing new properties from being added, existing properties from being removed, or their values from being changed.\n\nExample:\n\n```javascript\nconst obj = { name: 'John' };\nObject.freeze(obj);\nobj.name = 'Jane'; // This won't change the name\n```" + }, + { + "link": "#what-is-the-purpose-of-freeze-method", + "title": "What is the purpose of freeze method", + "url": "", + "level": "basic", + "theme": "JavaScript, objects", + "text": "### What is the purpose of freeze method?\n\nThe purpose of `Object.freeze()` is to make an object immutable. Once an object is frozen, you cannot alter its properties or add new ones, ensuring the integrity of the data.\n\nExample:\n\n```javascript\nconst obj = { key: 'value' };\nObject.freeze(obj);\nobj.key = 'new value'; // Won't work\n```" + }, + { + "link": "#why-do-i-need-to-use-freeze-method", + "title": "Why do I need to use freeze method", + "url": "", + "level": "basic", + "theme": "JavaScript, objects", + "text": "### Why do I need to use freeze method?\n\nUsing `Object.freeze()` is useful when you want to ensure that the object’s properties cannot be changed, helping to prevent bugs caused by unintended modifications.\n\nExample:\n\n```javascript\nconst config = { maxLimit: 100 };\nObject.freeze(config);\nconfig.maxLimit = 200; // Won't work\n```" + }, + { + "link": "#how-do-you-detect-a-browser-language-preference", + "title": "How do you detect a browser language preference", + "url": "", + "level": "basic", + "theme": "JavaScript, browser features", + "text": "### How do you detect a browser language preference?\n\nYou can detect the browser’s preferred language using `navigator.language` or `navigator.languages`.\n\nExample:\n\n```javascript\nconsole.log(navigator.language); // 'en-US'\n```" + }, + { + "link": "#how-to-convert-string-to-title-case-with-javascript", + "title": "How to convert string to title case with javascript", + "url": "", + "level": "basic", + "theme": "JavaScript, string manipulation", + "text": "### How to convert string to title case with JavaScript?\n\nYou can convert a string to title case by splitting the string into words, capitalizing the first letter of each word, and then joining them back together.\n\nExample:\n\n```javascript\nfunction toTitleCase(str) {\n return str.replace(/\\b(\\w)/g, char => char.toUpperCase());\n}\nconsole.log(toTitleCase('hello world')); // 'Hello World'\n```" + }, + { + "link": "#how-do-you-detect-javascript-disabled-in-the-page", + "title": "How do you detect javascript disabled in the page", + "url": "", + "level": "basic", + "theme": "JavaScript, page features", + "text": "### How do you detect JavaScript disabled in the page?\n\nYou can detect JavaScript being disabled by using `