Last active
August 4, 2022 04:13
-
-
Save rjoydip-zz/b04b6b8ffc536d5236eb49519d41894b to your computer and use it in GitHub Desktop.
Interview Question By Interviewer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @name - JavaScript Interview questions | |
*/ | |
//==== | |
/** | |
* @name - TypeOf | |
* @description - typeof [Number] | |
*/ | |
console.log(typeof 25 === "number"); | |
console.log(typeof 3.14 === "number"); | |
console.log(typeof 69 === "number"); | |
// log base 10 | |
console.log(typeof Math.LN10 === "number"); | |
console.log(typeof Infinity === "number"); | |
// Despite being "Not-A-Number" | |
console.log(typeof NaN === "number"); | |
// Wrapping in Number() function | |
console.log(typeof Number("100") === "number"); | |
/** | |
* @name - TypeOf | |
* @description - typeof [String] | |
*/ | |
console.log(typeof "" === "string"); | |
console.log(typeof "bla" === "string"); | |
// ES6 template literal | |
console.log(typeof `template literal` === "string"); | |
console.log(typeof "1" === "string"); | |
console.log(typeof typeof 1 === "string"); | |
// Wrapping inside String() function | |
console.log(typeof String(1) === "string"); | |
/** | |
* @name - TypeOf | |
* @description - typeof [Symbol] | |
*/ | |
console.log(typeof Symbol); // function | |
console.log(typeof Symbol("")); // symbol | |
console.log(typeof Symbol(1)); // symbol | |
/** | |
* @name - InstanceOf | |
* @description - instanceOf [Object] | |
*/ | |
console.log({} instanceof Object) // true | |
console.log(new Object() instanceof Object) // true | |
/** | |
* @name - InstanceOf | |
* @description - instanceOf [Function] | |
*/ | |
const fn = function () { } | |
console.log(fn instanceof Function) // true | |
console.log(fn instanceof Function.constructor) // true | |
/** | |
* @name - Hoisting | |
* @description - Loop example | |
*/ | |
for (var i = 10; i >= 0; i--) { | |
setTimeout(() => console.log(i), 10); | |
} | |
// Hoisting Example 2 | |
function x() { | |
setTimeout(function () { | |
console.log(i) // Output : 1 | |
}) | |
var i = 1 | |
} | |
x() | |
/** | |
* @name - Hoisting | |
* @description - Example-1 | |
*/ | |
var b = 10; | |
function abc() { | |
console.log(b); // undefined | |
console.log(b++); // null | |
var b = 3; | |
console.log(b); // 3 | |
} | |
abc(); | |
/** | |
* @name - Object Prototype | |
* @description - __proto__ instanceOf Object | |
* @link - https://dev.to/inambe/what-is-proto-javascript-191m | |
*/ | |
const obj = new Object(); | |
// console.log(obj.__proto__ instanceof Object); // false | |
// an object using object literal | |
const person = { | |
name: "John", | |
age: 30 | |
}; | |
// console.log(person.__proto__ === Object.prototype); // true | |
/** | |
* @name - Generator object | |
* @description - https://www.digitalocean.com/community/tutorials/understanding-generators-in-javascript | |
**/ | |
let Obj = { * foo () { yield ({ a: '1' }) } } | |
// To accing the value | |
Obj.foo().next() // Output : {value: {a:'1'}, done: false} | |
/** | |
* @name - Function Prototype | |
* @description - __proto__ instanceOf Function | |
* @link - ? | |
*/ | |
let fn1 = function () { } | |
// fn1.__proto__ === Object // false | |
// fn1.__proto__ === Object.prototype // false | |
// console.log(fn1.__proto__ instanceof Function.prototype) // Error | |
/** | |
* @name - Execution | |
* @description - Execution order | |
* @example - console vs process.nextTick vs setImmediate | |
*/ | |
console.log("console first"); | |
process.nextTick(() => console.log("process.nextTick")); // console second | |
setImmediate(() => console.log("setImmediate")); // console third | |
/** | |
* @name - Snake_case to Camel_case convert | |
*/ | |
const input = "this_is_a_snake_case_string"; | |
// Solution 1 | |
const camelCase = () => { | |
return str.replace(/[_][a-z]/ig, (m) => { | |
// m => _i, _a, _s | |
return m.toUpperCase().replace('_', '') | |
}); | |
} | |
// Solution 2 | |
const camelCase = (str) => { | |
return str.split('_').map((i, k) => k > 0 ? `${i.slice(0, 1).toString().toUpperCase()}${i.toString().slice(1,)}` : i).join('') | |
} | |
const output = camelCase(input); | |
console.log(output); // thisIsASnakeCaseString | |
/** | |
* @name - Closure example | |
*/ | |
function parent(name, message) { | |
const val = 1; | |
return function(param) { | |
return { val, name, message, param} | |
} | |
} | |
// Function calls | |
let p = parent('joy', 'hello') | |
obj(true) // Output : { 1, 'joy', 'hello', true } | |
/** | |
* @name - Difference | |
* @description - Difference between Map() vs WeekMap() | |
* @link - https://thisthat.dev/map-vs-weak-map/ | |
*/ | |
/** | |
* @name - Difference | |
* @description - Difference between Object.freez() vs Object.seal() | |
* @link - https://communicode.io/object-freeze-vs-object-seal-javascript/ | |
*/ | |
/** | |
* @question - How to utilize all cpus in node | |
* @link - https://blog.devgenius.io/how-to-scale-a-nodejs-application-a51d3e8e2d36 | |
*/ | |
/** | |
* @question - Difference beftween spawn vs fork in node.js | |
* @link - https://www.freecodecamp.org/news/node-js-child-processes-everything-you-need-to-know-e69498fe970a | |
* @link - https://www.geeksforgeeks.org/difference-between-spawn-and-fork-methods-in-node-js/ | |
*/ | |
/** | |
* @question - Reactive programing in JavaScript | |
* @link - https://javascript.plainenglish.io/reactive-programming-in-javascript-8373201a6618 | |
*/ | |
/** | |
* @question - Apply vs Bind vs Call | |
* @link - https://github.com/rjoydip/javascript-concepts/tree/main/call-vs-apply-vs-bind | |
*/ | |
/** | |
* @question - Hoisting | |
* @link - https://github.com/rjoydip/javascript-concepts/tree/main/hoisting | |
*/ | |
/** | |
* @question - Event Bubbling or Event Capturing | |
* @link - https://github.com/rjoydip/javascript-concepts/tree/main/event-bubbling | |
*/ | |
/** | |
* @question - How to secure node.js application | |
* @link - ? | |
*/ | |
/** | |
* @question - How to implement token authentication in node.js application | |
* @link - ? | |
*/ | |
/** | |
* @question - How to implement 2FA authentication in node.js application | |
* @question - How 2FA authentication mechanisam works | |
* @link - ? | |
*/ | |
/** | |
* @question - Shallow vs Deep Copies | |
* @link - https://www.freecodecamp.org/news/copying-stuff-in-javascript-how-to-differentiate-between-deep-and-shallow-copies-b6d8c1ef09cd | |
*/ | |
/** | |
* @question - for-of vs for-in | |
* @link - https://www.freecodecamp.org/news/javascript-loops-explained-for-loop-for | |
*/ | |
/** | |
* @question - How to create Node.js proxy server | |
* @link - https://www.twilio.com/blog/node-js-proxy-server | |
* @link - https://javascript.plainenglish.io/build-your-own-forward-and-reverse-proxy-server-using-node-js-from-scratch-eaa0f8d69e1f | |
*/ | |
/** | |
* @question - Sets vs. WeakSets & Maps vs. WeakMap | |
* @link - https://blog.logrocket.com/weakmap-weakset-understanding-javascript-weak-references/ | |
**/ | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @name - React.js Interview questions | |
*/ | |
//==== | |
/** | |
* @question - Class level component vs. Functional component | |
* @link - | |
**/ | |
/** | |
* @question - Profiler in react.js | |
* @link - | |
**/ | |
/** | |
* @question - HOC or higher order component | |
* @link - | |
**/ | |
/** | |
* @question - Props drilling | |
* @link - | |
**/ | |
/** | |
* @question - React lifecycle | |
* @link - | |
**/ | |
/** | |
* @question - Component composition | |
* @link - | |
**/ | |
/** | |
* @question - ref and ForwardRef | |
* @link - | |
**/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment