nitish24p / js-vault Goto Github PK
View Code? Open in Web Editor NEWList of tricky Javascript interview questions
Home Page: https://jsvault.com
License: Apache License 2.0
List of tricky Javascript interview questions
Home Page: https://jsvault.com
License: Apache License 2.0
This page design is completely an open choice.. As long as it fits the theme of the site
Implement a class / function / utility which exhibits an event dispatcher mechanism and the following methods are available
/**
* Implement an Event dispatcher
* which has a way to add listener, remove listeners
* and dispatch events
*
*
* EventDispatcher.addEventListener()
* EventDispatcher.removeEventListener()
* EventDispatcher.dispatch(Event)
*
*/
In array.map impl, why is there a element exists in the array check? What is that supposed to do?
Its literally taking that value out of the array in the previous line and checking if that exists in that line.
From what i know, the in-built impl doesn't protect against array modification. Is it trying to do that?
Atleast why not just check for undefined (say if length got modified).
I have got nothing against useless checks, but that check alone is bringing down the performance from o(n) to o(n**2).
function pipe() {
// Implement code here
}
const double = (x) => x * 2;
const square = (x) => x * x;
const cube = (x) => x ** 3;
// const value = pipe(double, cube, square)(2); // output 4096
// console.log(value);
Keep the pipe function as generic as possible..
Given a function as mentioned below. Write a utility, promisify, where the usage is as explained below
function asyncFunction(a, b, callback) {
const isError = Math.random() > 0.7;
setTimeout(() => {
if (isError) {
callback(null, new Error("Something went wrong"));
return;
}
callback(a + b, null);
}, 3000);
}
function promisify(fn) {
// Implement Code here
}
// Old ussage
asyncFunction(1,2, function(result, err) {
console.log(result,err)
})
// New Usage
const promisifiedFn = promisify(asyncFunction);
promisifiedFn(1, 2)
.then(res => {
console.log("result", res);
})
.catch(console.log);
The output is not being reflected inside the output model (Editor)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.