|
64 | 64 | | 14 | [What is a unary function](#what-is-a-unary-function) |
|
65 | 65 | | 15 | [What is the currying function](#what-is-the-currying-function) |
|
66 | 66 | | 16 | [What is a pure function](#what-is-a-pure-function) |
|
67 |
| -| 17 | [Benefits](#benefits) | |
| 67 | +| 17 | [What are the benefits of pure functions](#what-are-the-benefits-of-pure-functions) | |
68 | 68 | | 18 | [What is the purpose of the let keyword](#what-is-the-purpose-of-the-let-keyword) |
|
69 | 69 | | 19 | [What is the difference between let and var](#what-is-the-difference-between-let-and-var) |
|
70 | 70 | | 20 | [What is the reason to choose the name let as a keyword](#what-is-the-reason-to-choose-the-name-let-as-a-keyword) |
|
|
400 | 400 | | 350 | [What is the output of below console statement with unary operator](#what-is-the-output-of-below-console-statement-with-unary-operator) |
|
401 | 401 | | 351 | [Does javascript uses mixins](#does-javascript-uses-mixins) |
|
402 | 402 | | 352 | [Mixin Example using Object composition](#mixin-example-using-object-composition) |
|
403 |
| -| 353 | [Benefits](#benefits-1) | |
| 403 | +| 353 | [Benefits](#benefits) | |
404 | 404 | | 354 | [What is a thunk function](#what-is-a-thunk-function) |
|
405 | 405 | | 355 | [What are asynchronous thunks](#what-are-asynchronous-thunks) |
|
406 | 406 | | 356 | [What is the output of below function calls](#what-is-the-output-of-below-function-calls) |
|
|
973 | 973 |
|
974 | 974 | **[⬆ Back to Top](#table-of-contents)**
|
975 | 975 |
|
976 |
| -9. ### What is the difference between == and === operators |
| 976 | +9. ### What is the difference between == and === operators |
977 | 977 | JavaScript provides two types of equality operators:
|
978 | 978 |
|
979 | 979 | - **Loose equality (`==`, `!=`)**: Performs type conversion if the types differ, comparing values after converting them to a common type.
|
|
1114 | 1114 |
|
1115 | 1115 | **[⬆ Back to Top](#table-of-contents)**
|
1116 | 1116 |
|
1117 |
| -7. ### What is the currying function |
| 1117 | +15. ### What is the currying function |
1118 | 1118 |
|
1119 | 1119 | **Currying** is the process of transforming a function with **multiple arguments** into a sequence of **nested functions**, each accepting **only one argument** at a time.
|
1120 | 1120 |
|
|
1325 | 1325 |
|
1326 | 1326 | **[⬆ Back to Top](#table-of-contents)**
|
1327 | 1327 |
|
1328 |
| -25. ### How do you decode or encode a URL in JavaScript? |
| 1328 | +24. ### How do you decode or encode a URL in JavaScript? |
1329 | 1329 |
|
1330 | 1330 | `encodeURI()` function is used to encode an URL. This function requires a URL string as a parameter and return that encoded string.
|
1331 | 1331 | `decodeURI()` function is used to decode an URL. This function requires an encoded URL string as parameter and return that decoded string.
|
|
1340 | 1340 |
|
1341 | 1341 | **[⬆ Back to Top](#table-of-contents)**
|
1342 | 1342 |
|
1343 |
| -26. ### What is memoization |
| 1343 | +25. ### What is memoization |
1344 | 1344 |
|
1345 | 1345 | Memoization is a functional programming technique which attempts to increase a function’s performance by caching its previously computed results. Each time a memoized function is called, its parameters are used to index the cache. If the data is present, then it can be returned, without executing the entire function. Otherwise the function is executed and then the result is added to the cache.
|
1346 | 1346 | Let's take an example of adding function with memoization,
|
|
1368 | 1368 |
|
1369 | 1369 | **[⬆ Back to Top](#table-of-contents)**
|
1370 | 1370 |
|
1371 |
| -27. ### What is Hoisting |
| 1371 | +26. ### What is Hoisting |
1372 | 1372 |
|
1373 | 1373 | Hoisting is a JavaScript mechanism where variables, function declarations and classes are moved to the top of their scope before code execution. Remember that JavaScript only hoists declarations, not initialisation.
|
1374 | 1374 | Let's take a simple example of variable hoisting,
|
|
1400 | 1400 |
|
1401 | 1401 | **[⬆ Back to Top](#table-of-contents)**
|
1402 | 1402 |
|
1403 |
| -28. ### What are classes in ES6 |
| 1403 | +27. ### What are classes in ES6 |
1404 | 1404 |
|
1405 | 1405 | In ES6, Javascript classes are primarily syntactic sugar over JavaScript’s existing prototype-based inheritance.
|
1406 | 1406 | For example, the prototype based inheritance written in function expression as below,
|
|
1433 | 1433 |
|
1434 | 1434 | **[⬆ Back to Top](#table-of-contents)**
|
1435 | 1435 |
|
1436 |
| -29. ### What are closures |
| 1436 | +28. ### What are closures |
1437 | 1437 |
|
1438 | 1438 | A closure is the combination of a function bundled(enclosed) together with its lexical environment within which that function was declared. i.e, It is an inner function that has access to the outer or enclosing function’s variables, functions and other data even after the outer function has finished its execution. The closure has three scope chains.
|
1439 | 1439 |
|
|
1459 | 1459 |
|
1460 | 1460 | **[⬆ Back to Top](#table-of-contents)**
|
1461 | 1461 |
|
1462 |
| -30. ### What are modules |
| 1462 | +29. ### What are modules |
1463 | 1463 |
|
1464 | 1464 | Modules refer to small units of independent, reusable code and also act as the foundation of many JavaScript design patterns. Most of the JavaScript modules export an object literal, a function, or a constructor
|
1465 | 1465 |
|
1466 | 1466 | **[⬆ Back to Top](#table-of-contents)**
|
1467 | 1467 |
|
1468 |
| -31. ### Why do you need modules |
| 1468 | +30. ### Why do you need modules |
1469 | 1469 |
|
1470 | 1470 | Below are the list of benefits using modules in javascript ecosystem
|
1471 | 1471 |
|
|
1475 | 1475 |
|
1476 | 1476 | **[⬆ Back to Top](#table-of-contents)**
|
1477 | 1477 |
|
1478 |
| -32. ### What is scope in javascript |
| 1478 | +31. ### What is scope in javascript |
1479 | 1479 |
|
1480 | 1480 | Scope is the accessibility of variables, functions, and objects in some particular part of your code during runtime. In other words, scope determines the visibility of variables and other resources in areas of your code.
|
1481 | 1481 |
|
1482 | 1482 | **[⬆ Back to Top](#table-of-contents)**
|
1483 | 1483 |
|
1484 |
| -33. ### What is a service worker |
| 1484 | +32. ### What is a service worker |
1485 | 1485 |
|
1486 | 1486 | A Service worker is basically a script (JavaScript file) that runs in the background, separate from a web page and provides features that don't need a web page or user interaction. Some of the major features of service workers are Rich offline experiences(offline first web application development), periodic background syncs, push notifications, intercept and handle network requests and programmatically managing a cache of responses.
|
1487 | 1487 |
|
1488 | 1488 | **[⬆ Back to Top](#table-of-contents)**
|
1489 | 1489 |
|
1490 |
| -34. ### How do you manipulate DOM using a service worker |
| 1490 | +33. ### How do you manipulate DOM using a service worker |
1491 | 1491 |
|
1492 | 1492 | Service worker can't access the DOM directly. But it can communicate with the pages it controls by responding to messages sent via the `postMessage` interface, and those pages can manipulate the DOM.
|
1493 | 1493 |
|
1494 | 1494 | **[⬆ Back to Top](#table-of-contents)**
|
1495 | 1495 |
|
1496 |
| -35. ### How do you reuse information across service worker restarts |
| 1496 | +34. ### How do you reuse information across service worker restarts |
1497 | 1497 |
|
1498 | 1498 | The problem with service worker is that it gets terminated when not in use, and restarted when it's next needed, so you cannot rely on global state within a service worker's `onfetch` and `onmessage` handlers. In this case, service workers will have access to IndexedDB API in order to persist and reuse across restarts.
|
1499 | 1499 |
|
1500 | 1500 | **[⬆ Back to Top](#table-of-contents)**
|
1501 | 1501 |
|
1502 |
| -36. ### What is IndexedDB |
| 1502 | +35. ### What is IndexedDB |
1503 | 1503 |
|
1504 | 1504 | IndexedDB is a low-level API for client-side storage of larger amounts of structured data, including files/blobs. This API uses indexes to enable high-performance searches of this data.
|
1505 | 1505 |
|
1506 | 1506 | **[⬆ Back to Top](#table-of-contents)**
|
1507 | 1507 |
|
1508 |
| -37. ### What is web storage |
| 1508 | +36. ### What is web storage |
1509 | 1509 |
|
1510 | 1510 | Web storage is an API that provides a mechanism by which browsers can store key/value pairs locally within the user's browser, in a much more intuitive fashion than using cookies. The web storage provides two mechanisms for storing data on the client.
|
1511 | 1511 |
|
|
1514 | 1514 |
|
1515 | 1515 | **[⬆ Back to Top](#table-of-contents)**
|
1516 | 1516 |
|
1517 |
| -38. ### What is a post message |
| 1517 | +37. ### What is a post message |
1518 | 1518 |
|
1519 | 1519 | Post message is a method that enables cross-origin communication between Window objects.(i.e, between a page and a pop-up that it spawned, or between a page and an iframe embedded within it). Generally, scripts on different pages are allowed to access each other if and only if the pages follow same-origin policy(i.e, pages share the same protocol, port number, and host).
|
1520 | 1520 |
|
1521 | 1521 | **[⬆ Back to Top](#table-of-contents)**
|
1522 | 1522 |
|
1523 |
| -39. ### What is a Cookie |
| 1523 | +38. ### What is a Cookie |
1524 | 1524 |
|
1525 | 1525 | A cookie is a piece of data that is stored on your computer to be accessed by your browser. Cookies are saved as key/value pairs.
|
1526 | 1526 | For example, you can create a cookie named username as below,
|
|
1533 | 1533 |
|
1534 | 1534 | **[⬆ Back to Top](#table-of-contents)**
|
1535 | 1535 |
|
1536 |
| -40. ### Why do you need a Cookie |
| 1536 | +39. ### Why do you need a Cookie |
1537 | 1537 |
|
1538 | 1538 | Cookies are used to remember information about the user profile(such as username). It basically involves two steps,
|
1539 | 1539 |
|
|
1542 | 1542 |
|
1543 | 1543 | **[⬆ Back to Top](#table-of-contents)**
|
1544 | 1544 |
|
1545 |
| -41. ### What are the options in a cookie |
| 1545 | +40. ### What are the options in a cookie |
1546 | 1546 |
|
1547 | 1547 | There are few below options available for a cookie,
|
1548 | 1548 |
|
|
1560 | 1560 |
|
1561 | 1561 | **[⬆ Back to Top](#table-of-contents)**
|
1562 | 1562 |
|
1563 |
| -42. ### How do you delete a cookie |
| 1563 | +41. ### How do you delete a cookie |
1564 | 1564 |
|
1565 | 1565 | You can delete a cookie by setting the expiry date as a passed date. You don't need to specify a cookie value in this case.
|
1566 | 1566 | For example, you can delete a username cookie in the current page as below.
|
|
1574 | 1574 |
|
1575 | 1575 | **[⬆ Back to Top](#table-of-contents)**
|
1576 | 1576 |
|
1577 |
| -43. ### What are the differences between cookie, local storage and session storage |
| 1577 | +42. ### What are the differences between cookie, local storage and session storage |
1578 | 1578 |
|
1579 | 1579 | Below are some of the differences between cookie, local storage and session storage,
|
1580 | 1580 |
|
|
1589 | 1589 |
|
1590 | 1590 | **[⬆ Back to Top](#table-of-contents)**
|
1591 | 1591 |
|
1592 |
| -44. ### What is the main difference between localStorage and sessionStorage |
| 1592 | +43. ### What is the main difference between localStorage and sessionStorage |
1593 | 1593 |
|
1594 | 1594 | LocalStorage is the same as SessionStorage but it persists the data even when the browser is closed and reopened(i.e it has no expiration time) whereas in sessionStorage data gets cleared when the page session ends.
|
1595 | 1595 |
|
1596 | 1596 | **[⬆ Back to Top](#table-of-contents)**
|
1597 | 1597 |
|
1598 |
| -45. ### How do you access web storage |
| 1598 | +44. ### How do you access web storage |
1599 | 1599 |
|
1600 | 1600 | The Window object implements the `WindowLocalStorage` and `WindowSessionStorage` objects which has `localStorage`(window.localStorage) and `sessionStorage`(window.sessionStorage) properties respectively. These properties create an instance of the Storage object, through which data items can be set, retrieved and removed for a specific domain and storage type (session or local).
|
1601 | 1601 | For example, you can read and write on local storage objects as below
|
|
1607 | 1607 |
|
1608 | 1608 | **[⬆ Back to Top](#table-of-contents)**
|
1609 | 1609 |
|
1610 |
| -46. ### What are the methods available on session storage |
| 1610 | +45. ### What are the methods available on session storage |
1611 | 1611 |
|
1612 | 1612 | The session storage provided methods for reading, writing and clearing the session data
|
1613 | 1613 |
|
|
1627 | 1627 |
|
1628 | 1628 | **[⬆ Back to Top](#table-of-contents)**
|
1629 | 1629 |
|
1630 |
| -47. ### What is a storage event and its event handler |
| 1630 | +46. ### What is a storage event and its event handler |
1631 | 1631 |
|
1632 | 1632 | The StorageEvent is an event that fires when a storage area has been changed in the context of another document. Whereas onstorage property is an EventHandler for processing storage events.
|
1633 | 1633 | The syntax would be as below
|
|
1654 | 1654 |
|
1655 | 1655 | **[⬆ Back to Top](#table-of-contents)**
|
1656 | 1656 |
|
1657 |
| -48. ### Why do you need web storage |
| 1657 | +47. ### Why do you need web storage |
1658 | 1658 |
|
1659 | 1659 | Web storage is more secure, and large amounts of data can be stored locally, without affecting website performance. Also, the information is never transferred to the server. Hence this is a more recommended approach than Cookies.
|
1660 | 1660 |
|
1661 | 1661 | **[⬆ Back to Top](#table-of-contents)**
|
1662 | 1662 |
|
1663 |
| -49. ### How do you check web storage browser support |
| 1663 | +48. ### How do you check web storage browser support |
1664 | 1664 |
|
1665 | 1665 | You need to check browser support for localStorage and sessionStorage before using web storage,
|
1666 | 1666 |
|
|
1674 | 1674 |
|
1675 | 1675 | **[⬆ Back to Top](#table-of-contents)**
|
1676 | 1676 |
|
1677 |
| -50. ### How do you check web workers browser support |
| 1677 | +49. ### How do you check web workers browser support |
1678 | 1678 |
|
1679 | 1679 | You need to check browser support for web workers before using it
|
1680 | 1680 |
|
|
1688 | 1688 |
|
1689 | 1689 | **[⬆ Back to Top](#table-of-contents)**
|
1690 | 1690 |
|
1691 |
| -51. ### Give an example of a web worker |
| 1691 | +50. ### Give an example of a web worker |
1692 | 1692 |
|
1693 | 1693 | You need to follow below steps to start using web workers for counting example
|
1694 | 1694 |
|
|
1739 | 1739 |
|
1740 | 1740 | **[⬆ Back to Top](#table-of-contents)**
|
1741 | 1741 |
|
1742 |
| -52. ### What are the restrictions of web workers on DOM |
| 1742 | +51. ### What are the restrictions of web workers on DOM |
1743 | 1743 |
|
1744 | 1744 | WebWorkers don't have access to below javascript objects since they are defined in an external files
|
1745 | 1745 |
|
|
0 commit comments