Skip to content

Instantly share code, notes, and snippets.

@skant09
Last active August 15, 2021 17:03
Show Gist options
  • Save skant09/2168d781d5549a38474779d69663448d to your computer and use it in GitHub Desktop.
Save skant09/2168d781d5549a38474779d69663448d to your computer and use it in GitHub Desktop.
Javascript interview question

Implement jQuery

$('.class').add('asdasd').css('background-color:black');

Implement Promise polyfill


Implement Promise.all


What will be the output?

var constant = "outside"

function log(){
    console.log(constant);
    var constant = "inside";
}
console.log(constant)
log();

Implement add(1)(2)();

function add(input) {
	return function (anotherInput){
		console.log(typeof input)
		if(typeof input === 'number'){
			return add(input + anotherInput);
		} else {
			return input
		}
	}
}

Tell the output

console.log(1)
setTimeout(()=>{
	console.log(2)
},0)
console.log(Promise.resolve(3))
console.log(4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment