└── readme.md /readme.md: -------------------------------------------------------------------------------- 1 | ## Q2. What are the differences between var, let and const? 2 | 3 | ### var - 4 | 1. Redeclare and reinitilized 5 | 2. Global scope and Function Scope 6 | 3. Hoisting 7 | 4. Used before introduce ES6 8 | ### let 9 | 1. not Redeclare and reinitilized 10 | 2. no Hoisting 11 | 3. Block scope, Global Scope 12 | 4. TDZ 13 | 5. introduce in ES6 14 | ### const 15 | 1. not Redeclare and Not reinitilized 16 | 2. no Hoisting 17 | 3. Block scope, Global Scope 18 | 4. TDZ 19 | 5. introduce in ES6 20 | 21 | ## Type of Scope 22 | 1. Global Scope 23 | 2. Function Scope 24 | 3. Block Scope 25 | 26 | ## Q3. Hoisting - Hoisting is the js mechanism where var and function declaration are moved to top of their scope before code execution. 27 | 1. function Hoisting 28 | 2. var keyword Hoisting 29 | ## Q4. What is a Temporal Dead Zone (TDZ)? 30 | - when trying to acceess a variable before it's decleration with let and const keyword. 31 | - introduce to imporve the code quality by detecting & preventing to use variable. 32 | ## Q5. What is meant by first class functions? 33 | - Assign a function to a variable is first class function. 34 | ## Q6 . Pure Function - A pure function in JavaScript is a function that returns the same result if the same arguments(input) are passed in the function. 35 | --- 36 | ## Q7. Execution Context 37 | 38 | - This is for Synchronous JavaScript 39 | 1. Global Execution Context 40 | 2. Function Execution context 41 | 3. Memory Allocation 42 | 4. Code Execution 43 | 5. Call Stack 44 | 45 | - Asynchronous JavaScript 46 | 1. Event Loop 47 | 2. Callback queue 48 | 3. Microtask Queue 49 | 4. Call Stack 50 | 51 | --- 52 | # 19th June 53 | 54 | ## Chrome - V8 Engine 55 | ## Safari - JavaScriptCore (Nitro) 56 | ## Firefox - Spider Monkey 57 | 58 | ## What is the spread operator? 59 | - Spread operator allows us to destructure the non-primitive datatype like object and array to access elemnets individually. 60 | - The spread operator is a feature in JavaScript that allows an iterable (such as an array or a string) to be expanded into individual elements. The spread operator is denoted by three dots (...). 61 | - The JavaScript spread operator ( ... ) allows us to quickly copy all or part of an existing array or object into another array or object. 62 | 63 | ## What is use of setTimeout? 64 | - it is used to delay the output with given time. 65 | - The setTimeout() method sets a timer which executes a function or specified piece of code once the timer expires. 66 | ## What is setInterval? 67 | - They are going to excute the code after given time peroid. 68 | 69 | ## What are callbacks? 70 | - A function that can pass inside another function as an argument. 71 | - A callback is a function that passed as an argument to another function. 72 | ## Callback Hell 73 | - Callback Hell is essentially nested callbacks stacked below one another forming a pyramid structure. 74 | 75 | ## Difference between undefined vs not defined vs NaN? 76 | 1. undefine - variable dec. but not init. 77 | 2. not define - variable is not declear. 78 | 3. NaN - Not a Number 79 | 80 | --- 81 | # Day 3 - 20th June 2023 82 | 83 | ## What are promises and why do we need them? 84 | - Promise are use to handle async operation in JS. easy to handle callback hell, also use to handle the error. 85 | - basically in promise there are Three stage 86 | 1. Pending 87 | 2. Resolve - (then method) 88 | 3. reject - (catch mentod) 89 | - initial stage of any promise is always pending. 90 | 91 | ## Q - We have three promise, and we want to combine all then and catch method by using Promise.all. 92 | 93 | ## What is promise chaining? 94 | - its a technique to chain multiple asynchronous operation together using promises. 95 | - Promise chaining is a technique in JavaScript to execute multiple asynchronous operations in a specific order by chaining promises together using the then method 96 | - Multiple .then method. 97 | 98 | ## DOM - Document Object Model 99 | - Document object model. basically it is javascript mechanism by which we can change the document structure, style, and content. 100 | - DOM is the data representation of the objects that comprise the structure and content of a document on the web. 101 | - Different method in DOM 102 | - Id - getElementById - return unique value 103 | - querySelector - return unique value 104 | - Class - getElementsByClassName 105 | - tag Name - getElementsByTagName 106 | - querySelectorAll 107 | 108 | - addEventListener - (event, callback function) 109 | 110 | ## Closure - 111 | - A closure is the combination of a function bundled together (enclosed) with references to its surrounding state (the lexical environment). 112 | - Closure is the combination of two function (min). 113 | - inner function is able to excess the outer function variable but vise-varsa not possible. 114 | - outer func and inner func is going to create a Lixical environment. 115 | 116 | ## How many operators do we have in JS ? 117 | 1. Arithemic operator 118 | 1. Add, Sub, Multi, Div(/), Module (%), Expontial (**), increment ++, decrement-- 119 | 2. Assignment Operator 120 | 1. Assign (=), Add Assign (+=), Sub Assign (-=), (*=), (/=), (%=) 121 | 3. Bitwise Operator 122 | 1. Bitwise OR (|), Bitwise AND (&), Bitwise NOT (~), Left shift (<<), right shift(>>) 123 | 4. Comparision Operator 124 | 1. equal (==), strict equal (===), Not equal (!=), Strict Not equal (!==), greate than, less than, greate than equal, less than equal 125 | 5. Logical Operator 126 | 1. AND (&&) 127 | 2. OR (||) 128 | 3. Not (!) 129 | 6. Ternary Operator 130 | 1. (Condition) ? "Execute True Condition" : "Execute False Condition" 131 | 7. typeof Operator 132 | 1. return datatype 133 | 134 | ## What are objects in javascript? 135 | - Non-premitive data type 136 | - store date in the form of Key-Value pair saparated by colon. 137 | - Key - Properties : Value 138 | 139 | # Day 4 - 21st June 2023 140 | 141 | ## Function Constructor - 142 | - A function constructor is a way to create a object using a function as a blue print or template. 143 | - it allow you to define a reusable structure for creating multiple object with similar properties and method. 144 | 145 | ## Call, Apply and Bind - 146 | - These all three methods are used to invoke a function where we are supposed to pass an object as first argument and at the time of definition we don't have mention this object as a parameter and we can access the values of object by using this keyword in function definition. 147 | - Call : The call method is used to invoked a function with a specific 'this' value, and arguments provide individuly. 148 | - The call() method invokes a function in which first argument will be the object and rest of the arguments required by function will be provided as an individual arguments. 149 | - Apply : Apply is similar with call, but take argument as an array. 150 | - The apply() method invokes a function in which first argument will be the object and rest of the arguments will be passed as an array of elements. 151 | - Bind - Bind is a function that helps you create another function that you can execute later with the new context of this that is provided. 152 | - The bind() method returns a new function and this function will be having the reference of the object passed, now whenever you want to use this returned function in the code you can use it by passing rest of the arguments. 153 | 154 | ## Async/Await - 155 | - An async function is a function declared with the async keyword, and the await keyword is permitted within it. The async and await keywords enable asynchronous, promise-based behavior to be written in a cleaner style, avoiding the need promise chains. 156 | 157 | 158 | ## Inheritance: 159 | - Inheritance is a fundamental concept in object-oriented programming that allows objects to inherit properties and methods from other objects. It enables code reuse, promotes modularity, and facilitates the creation of hierarchical relationships between objects. 160 | - In JavaScript, inheritance is typically achieved through prototype-based inheritance. Objects in JavaScript can have a prototype, which is another object from which they inherit properties and methods. 161 | 162 | ## Prototype: 163 | - The prototype is an object that is associated with every JavaScript object. It serves as a blueprint or template for creating new objects through inheritance. The prototype object contains properties and methods that are shared among all instances created from it. 164 | - --------------------------------------------------------------------------------