Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Sushant2435 committed Jul 29, 2024
1 parent bc35f79 commit a76f207
Show file tree
Hide file tree
Showing 10 changed files with 158 additions and 40 deletions.
68 changes: 34 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ a = "Hello";
console.log(a); // "Hello";
```
##
[Back to Top](#javascript-basics)
[Back to Top](#javascript-most-asked-interview-questions)

### Q2. What are the different datatypes in JavaScript? (Most asked)

Expand All @@ -67,7 +67,7 @@ console.log(a); // "Hello";
- Object
- Date
##
[Back to Top](#javascript-basics)
[Back to Top](#javascript-most-asked-interview-questions)

### Q3. What is Hoisting in JavaScript? (Most asked)
- In other scripting/server side languages, variables or functions must be declared before using it.
Expand All @@ -81,7 +81,7 @@ console.log(a); // "Hello";
- let and const - Hoisted but not initialized. (Temporal dead zone).
- class declarations - Hoisted but not initialized.
##
[Back to Top](#javascript-basics)
[Back to Top](#javascript-most-asked-interview-questions)

### Q4. What is temporal dead zone ?
- It is a specific time period in the execution of javascript code where the variables declared with let and const exists but cannot be accessed until the value is assigned.
Expand All @@ -95,7 +95,7 @@ function somemethod() {
}
```
##
[Back to Top](#javascript-basics)
[Back to Top](#javascript-most-asked-interview-questions)

### Q5. What are the differences let, var and const ? (Most asked)

Expand All @@ -112,7 +112,7 @@ function somemethod() {
- `let` and `const` are hoisted to the top of the block scope but do not get assigned any value (temporal dead zone).

##
[Back to Top](#javascript-basics)
[Back to Top](#javascript-most-asked-interview-questions)

### Q6. List out some key features of ES6. (Most asked)

Expand All @@ -129,7 +129,7 @@ function somemethod() {

👉 **Interview Tip:** Explain these features with these simple definitions to make good use of 2-3 minutes of interview time.
##
[Back to Top](#javascript-basics)
[Back to Top](#javascript-most-asked-interview-questions)

### Q7. What are limitations of arrow functions in javascript ?
- Arrow functions are introduced in ES6. They are simple and shorter way to write functions in javascript.
Expand All @@ -140,7 +140,7 @@ function somemethod() {
- Arrow functions cannot be used as generator functions.
- 👉 **Note:** Arrow functions + this combination questions will be asked here. Please explore on this combinations.
##
[Back to Top](#javascript-basics)
[Back to Top](#javascript-most-asked-interview-questions)

### Q8. What’s the spread operator in javascript ?
Spread operator is used to spread or expand the elements of an iterable like array or string into individual elements.
Expand All @@ -165,7 +165,7 @@ let a = […x] // 1,2
```
- **👉 Interview Tip**: Practice the above examples mentioned and showcase them in interviews to make interviewer think that you are a practical person. 😉
##
[Back to Top](#javascript-basics)
[Back to Top](#javascript-most-asked-interview-questions)

### Q9. What is rest operator in javascript ?
- Rest operator is used to condense multiple elements into single array or object.
Expand All @@ -177,7 +177,7 @@ let a = […x] // 1,2
Example(1,2,3,4);
```
##
[Back to Top](#javascript-basics)
[Back to Top](#javascript-most-asked-interview-questions)

- It is introduced in Es6.
- It allows us to assign the object properties and array values to distinct variables.
Expand All @@ -195,7 +195,7 @@ const [a,b] = [1,2];
console.log(a,b) // 1,2
```
##
[Back to Top](#javascript-basics)
[Back to Top](#javascript-most-asked-interview-questions)

### Q10. What are the differences between Map and Set ?

Expand Down Expand Up @@ -243,7 +243,7 @@ let data = new Set();
Sushant
```
##
[Back to Top](#javascript-basics)
[Back to Top](#javascript-most-asked-interview-questions)
### Q11. What are modules in javascript ?
- Modules allows us to break down the large piece of code into smaller parts.
- Modules helps us to write more reusable and maintenable code.
Expand Down Expand Up @@ -280,14 +280,14 @@ In Pass by reference, parameters passed as an arguments does not creates their o
console.log(arr); // Output: [1, 2, 3, 4]
```
##
[Back to Top](#javascript-basics)
[Back to Top](#javascript-most-asked-interview-questions)

### Q13. What is the difference between map and filter ? (Frequently asked)
- Both map and filter are useful in JavaScript when working with an arrays.
- map transforms each element of an array and creates a new array which contains the transformed elements. whereas filter will creates a new array with only those elements which satisfies the specified condition.

##
[Back to Top](#javascript-basics)
[Back to Top](#javascript-most-asked-interview-questions)

### Q14. What is the difference between map() and forEach() (Frequently asked)
- map method is used to transform the elements of an array. Whereas forEach method is used to loop through the elements of an array.
Expand All @@ -312,7 +312,7 @@ numbers.forEach((number) => {
```

##
[Back to Top](#javascript-basics)
[Back to Top](#javascript-most-asked-interview-questions)

### Q15. What is the difference between for-in and for-of ?
Both for-in and for-of are used to iterate over the datastructure.
Expand Down Expand Up @@ -353,7 +353,7 @@ for (let fruit of fruits) {
```

##
[Back to Top](#javascript-basics)
[Back to Top](#javascript-most-asked-interview-questions)

### Q16. What is difference between find vs findIndex ?
**find:**
Expand Down Expand Up @@ -385,7 +385,7 @@ for (let fruit of fruits) {
2
```
##
[Back to Top](#javascript-basics)
[Back to Top](#javascript-most-asked-interview-questions)

### Q17. What is the difference between Pure and Impure functions?
**Pure Functions:**
Expand All @@ -411,7 +411,7 @@ console.log(greeting("Sushant Sharma"));
```

##
[Back to Top](#javascript-basics)
[Back to Top](#javascript-most-asked-interview-questions)
### Q18. What are the differences between call(), apply() and bind() ? (Frequently asked)
- Call method will invoke the function immediately with the given this value and allows us to pass the arguments one by one with comma separator.
- Apply method will invoke the function immediately with given this value and allows us to pass the arguments as an array.
Expand Down Expand Up @@ -463,7 +463,7 @@ greetPerson('!')
```

##
[Back to Top](#javascript-basics)
[Back to Top](#javascript-most-asked-interview-questions)
### Q19. What are the different ways to create object in javascript ? (Most asked)
**Object literal :**
```
Expand Down Expand Up @@ -503,7 +503,7 @@ let lesson = {
```

##
[Back to Top](#javascript-basics)
[Back to Top](#javascript-most-asked-interview-questions)

### Q20. Whats the difference between Object.keys,values and entries ?
- Object.keys(): This will return the array of keys
Expand All @@ -521,7 +521,7 @@ let lesson = {
```

##
[Back to Top](#javascript-basics)
[Back to Top](#javascript-most-asked-interview-questions)

### Q21. Whats the difference between Object.freeze() vs Object.seal()
**Object.freeze:**
Expand Down Expand Up @@ -564,7 +564,7 @@ let lesson = {


##
[Back to Top](#javascript-basics)
[Back to Top](#javascript-most-asked-interview-questions)
### Q22. What is generator function in javascript ?
A generator function is a function which can be paused and resumed at any point during execution.
They are defined by using function* and it contains one or more yield expressions.
Expand All @@ -588,7 +588,7 @@ function* generatorFunction() {
```

##
[Back to Top](#javascript-basics)
[Back to Top](#javascript-most-asked-interview-questions)
### Q23. What is IIFE ?
IIFE means immediately invoked function expression.
functions which are executed immediately once they are mounted to the stack is called iife.
Expand All @@ -599,7 +599,7 @@ They does not require any explicit call to invoke the function.
})()
```
##
[Back to Top](#javascript-basics)
[Back to Top](#javascript-most-asked-interview-questions)

### Q24. What is CORS ? (Most asked)
👉 **Interview Tip:** This defination is more than enough so prepare this below answer well.
Expand All @@ -609,7 +609,7 @@ cors works by adding specific http headers to control which origins have access
Good Reference: https://dev.to/lydiahallie/cs-visualized-cors-5b8h

##
[Back to Top](#javascript-basics)
[Back to Top](#javascript-most-asked-interview-questions)
### Q25. What are the difference between typescript and javascript ?
- Typescript is the superset of javascript and has all the object oriented features.
- Javascript is a dynamically typed language whereas typescript is a statically typed language.
Expand All @@ -622,7 +622,7 @@ Good Reference: https://dev.to/lydiahallie/cs-visualized-cors-5b8h


##
[Back to Top](#javascript-basics)
[Back to Top](#javascript-most-asked-interview-questions)

### Q26. What is authentication vs authorization ? (Most asked)

Expand All @@ -635,20 +635,20 @@ Good Reference: https://www.youtube.com/watch?v=7Q17ubqLfaM


##
[Back to Top](#javascript-basics)
[Back to Top](#javascript-most-asked-interview-questions)
### Q27. What are the differences between null and undefined ?
**Null:**
If we assign null to a variable, it means it will not have any value
**Undefined:**
means the variable has been declared but not assigned any value yet.

##
[Back to Top](#javascript-basics)
[Back to Top](#javascript-most-asked-interview-questions)

### Q28. What is the difference between == and === in javascript ?
== will check for equality of values where as === willl check for equality as well as datatypes.
##
[Back to Top](#javascript-basics)
[Back to Top](#javascript-most-asked-interview-questions)

### Q29. Slice vs Splice in javascript ? (Most helpful in problem solving)
**Slice:**
Expand All @@ -670,7 +670,7 @@ If we want to add/delete/replace the existing elements in the array, then we wil
console.log(newArr); // [3,4,5,0]
```
##
[Back to Top](#javascript-basics)
[Back to Top](#javascript-most-asked-interview-questions)

### Q30. What is setTimeOut in javascript ?
setTimeOut is used to call a function or evaluate an expression after a specific number of milliseconds.
Expand All @@ -685,7 +685,7 @@ console.log("Prints Hello after 2 seconds")


##
[Back to Top](#javascript-basics)
[Back to Top](#javascript-most-asked-interview-questions)

### Q31. What is setInterval in javascript ?
setInterval method is used to call a function or evaluate an expression at specific intervals.
Expand All @@ -697,7 +697,7 @@ setInterval(function(){
👉 **Interview Tip:** Most asked in output based and problem solving so learn syntax more. Practice some examples.

##
[Back to Top](#javascript-basics)
[Back to Top](#javascript-most-asked-interview-questions)
### Q32. What are Promises in javascript ?
👉 **Interview Tip:** When this is asked cover all below points so that he will not ask any other question on promises 😈.
Promise is an object which represents the eventual completion or failure of an asynchronous operation in javascript.
Expand All @@ -721,12 +721,12 @@ let promise = new Promise((res, rej) => {
promise.then(res => console.log(res)).catch(rej => console.log(rej))
```
##
[Back to Top](#javascript-basics)
[Back to Top](#javascript-most-asked-interview-questions)
### Q33. What is a callstack in javascript ?
- Callstack will maintain the order of execution of execution contexts.

##
[Back to Top](#javascript-basics)
[Back to Top](#javascript-most-asked-interview-questions)

### Q34. What is a closure ? (Most asked in all the interviews 99% chance)
Defination: A function along with its outer environment together forms a closure
Expand Down Expand Up @@ -805,4 +805,4 @@ function createPerson(name) {
};
}
```
[Back to Top](#javascript-basics)
[Back to Top](#javascript-most-asked-interview-questions)
1 change: 1 addition & 0 deletions async.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
// console.log("hii")



// function fetchData(callback) {
// setTimeout(() => {
// callback("Hello")
Expand Down
20 changes: 20 additions & 0 deletions coding_series/10_ele_arr.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Write a JavaScript program that prints the elements of the following array.
const arr = [[1, 2, 1, 24], [8, 11, 9, 4], [7, 0, 7, 27], [7, 4, 28, 14], [3, 10, 26, 7]];

//using nested loop

for (let i = 0; i < arr.length; i++) {
console.log(`row ${i}`)
for (let j = 0; j < arr[i].length; j++) {
console.log(`${arr[i][j]}`)
}
}

// using for each method

arr.forEach((row, i) => {
console.log(`row ${i}`);
row.forEach(value => {
console.log(value);
});
});
15 changes: 15 additions & 0 deletions coding_series/11_sum_of_squares.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Write a JavaScript program to find the sum of squares of a numerical vector.
const arr = [0, 1, 2, 3, 4]

// using reduce method
const sumOfSquares = arr.reduce((acc, val) => acc + (val * val), 0)
console.log(sumOfSquares)

// using loop method

let sum = 0;
for (const num of arr) {
let num_sqr = num * num
sum = sum + num_sqr
}
console.log(sum)
23 changes: 23 additions & 0 deletions coding_series/12_sum_prod_arr.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Write a JavaScript program to compute the sum and product of an array of integers.

const arr = [1, 2, 3, 4, 5, 6]

// using reduce method
const result = arr.reduce((acc, val) => {
return {
sum: acc.sum + val,
prod: acc.prod * val
};
}, { sum: 0, prod: 1 });

console.log(result);

// using loop method

let sum = 0;
let prod = 1;
for (const num of arr) {
sum = sum + num;
prod = prod * num;
}
console.log(`sum is ${sum} and Product is ${prod}`)
Loading

0 comments on commit a76f207

Please sign in to comment.