Skip to content

Latest commit

 

History

History
1356 lines (1078 loc) · 22.9 KB

File metadata and controls

1356 lines (1078 loc) · 22.9 KB

Coding Questions

Hoisting

1. console.log(employeeId);

  1. Some Value
  2. Undefined
  3. Type Error
  4. ReferenceError: employeeId is not defined

Answer: 4) ReferenceError: employeeId is not defined

2. What would be the output of following code?

console.log(employeeId);
var employeeId = '19000';
  1. Some Value
  2. undefined
  3. Type Error
  4. ReferenceError: employeeId is not defined

Answer: 2) undefined

3. What would be the output of following code?

var employeeId = '1234abe';
(function(){
	console.log(employeeId);
	var employeeId = '122345';
})();
  1. '122345'
  2. undefined
  3. Type Error
  4. ReferenceError: employeeId is not defined

Answer: 2) undefined

4. What would be the output of following code?

var employeeId = '1234abe';
(function() {
	console.log(employeeId);
	var employeeId = '122345';
	(function() {
		var employeeId = 'abc1234';
	}());
}());
  1. '122345'
  2. undefined
  3. '1234abe'
  4. ReferenceError: employeeId is not defined

Answer: 2) undefined

5. What would be the output of following code?

(function() {
	console.log(typeof displayFunc);
	var displayFunc = function(){
		console.log("Hi I am inside displayFunc");
	}
}());
  1. undefined
  2. function
  3. 'Hi I am inside displayFunc'
  4. ReferenceError: displayFunc is not defined

Answer: 1) undefined

6. What would be the output of following code?

var employeeId = 'abc123';
function foo(){
	employeeId = '123bcd';
	return;
}
foo();
console.log(employeeId);
  1. undefined
  2. '123bcd'
  3. 'abc123'
  4. ReferenceError: employeeId is not defined

Answer: 2) '123bcd'

7. What would be the output of following code?

var employeeId = 'abc123';

function foo() {
	employeeId = '123bcd';
	return;

	function employeeId() {}
}
foo();
console.log(employeeId);
  1. undefined
  2. '123bcd'
  3. 'abc123'
  4. ReferenceError: employeeId is not defined

Answer: 3) 'abc123'

8. What would be the output of following code?

var employeeId = 'abc123';

function foo() {
	employeeId();
	return;

	function employeeId() {
		console.log(typeof employeeId);
	}
}
foo();
  1. undefined
  2. function
  3. string
  4. ReferenceError: employeeId is not defined

Answer: 2) 'function'

9. What would be the output of following code?

function foo() {
	employeeId();
	var product = 'Car';
	return;

	function employeeId() {
		console.log(product);
	}
}
foo();
  1. undefined
  2. Type Error
  3. 'Car'
  4. ReferenceError: product is not defined

Answer: 1) undefined

10. What would be the output of following code?

(function foo() {
	bar();

	function bar() {
		abc();
		console.log(typeof abc);
	}

	function abc() {
		console.log(typeof bar);
	}
}());
  1. undefined undefined
  2. Type Error
  3. function function
  4. ReferenceError: bar is not defined

Answer: 3) function function

Object

1. What would be the output of following code ?

(function() {
	'use strict';

	var person = {
		name: 'John'
	};
	person.salary = '10000$';
	person['country'] = 'USA';

	Object.defineProperty(person, 'phoneNo', {
		value: '8888888888',
		enumerable: true
	})

	console.log(Object.keys(person));
})();
  1. Type Error
  2. undefined
  3. ["name", "salary", "country", "phoneNo"]
  4. ["name", "salary", "country"]

Answer: 3) ["name", "salary", "country", "phoneNo"]

2. What would be the output of following code ?

(function() {
	'use strict';

	var person = {
		name: 'John'
	};
	person.salary = '10000$';
	person['country'] = 'USA';

	Object.defineProperty(person, 'phoneNo', {
		value: '8888888888',
		enumerable: false
	})

	console.log(Object.keys(person));
})();
  1. Type Error
  2. undefined
  3. ["name", "salary", "country", "phoneNo"]
  4. ["name", "salary", "country"]

Answer: 4) ["name", "salary", "country"]

3. What would be the output of following code ?

(function() {
	var objA = {
		foo: 'foo',
		bar: 'bar'
	};
	var objB = {
		foo: 'foo',
		bar: 'bar'
	};
	console.log(objA == objB);
	console.log(objA === objB);
}());
  1. false true
  2. false false
  3. true false
  4. true true

Answer: 2) false false

4. What would be the output of following code ?

(function() {
	var objA = new Object({foo: "foo"});
	var objB = new Object({foo: "foo"});
	console.log(objA == objB);
	console.log(objA === objB);
}());
  1. false true
  2. false false
  3. true false
  4. true true

Answer: 2) false false

5. What would be the output of following code ?

(function() {
	var objA = Object.create({
		foo: 'foo'
	});
	var objB = Object.create({
		foo: 'foo'
	});
	console.log(objA == objB);
	console.log(objA === objB);
}());
  1. false true
  2. false false
  3. true false
  4. true true

Answer: 2) false false

6. What would be the output of following code ?

(function() {
	var objA = Object.create({
		foo: 'foo'
	});
	var objB = Object.create(objA);
	console.log(objA == objB);
	console.log(objA === objB);
}());
  1. false true
  2. false false
  3. true false
  4. true true

Answer: 2) false false

7. What would be the output of following code ?

(function() {
	var objA = Object.create({
		foo: 'foo'
	});
	var objB = Object.create(objA);
	console.log(objA.toString() == objB.toString());
	console.log(objA.toString() === objB.toString());
}());
  1. false true
  2. false false
  3. true false
  4. true true

Answer: 4) true true

8. What would be the output of following code ?

(function() {
	var objA = Object.create({
		foo: 'foo'
	});
	var objB = objA;
	console.log(objA == objB);
	console.log(objA === objB);
	console.log(objA.toString() == objB.toString());
	console.log(objA.toString() === objB.toString());
}());
  1. true true true false
  2. true false true true
  3. true true true true
  4. true true false false

Answer: 3) true true true true

9. What would be the output of following code ?

(function() {
	var objA = Object.create({
		foo: 'foo'
	});
	var objB = objA;
	objB.foo = 'bar';
	console.log(objA.foo);
	console.log(objB.foo);
}());
  1. foo bar
  2. bar bar
  3. foo foo
  4. bar foo

Answer: 2) bar bar

10. What would be the output of following code ?

(function() {
	var objA = Object.create({
		foo: 'foo'
	});
	var objB = objA;
	objB.foo = 'bar';

	delete objA.foo;
	console.log(objA.foo);
	console.log(objB.foo);
}());
  1. foo bar
  2. bar bar
  3. foo foo
  4. bar foo

Answer: 3) foo foo

11. What would be the output of following code ?

(function() {
	var objA = {
		foo: 'foo'
	};
	var objB = objA;
	objB.foo = 'bar';

	delete objA.foo;
	console.log(objA.foo);
	console.log(objB.foo);
}());
  1. foo bar
  2. undefined undefined
  3. foo foo
  4. undefined bar

Answer: 2) undefined undefined

Array

1. What would be the output of following code?

(function() {
	var array = new Array('100');
	console.log(array);
	console.log(array.length);
}());
  1. undefined undefined
  2. [undefined × 100] 100
  3. ["100"] 1
  4. ReferenceError: array is not defined

Answer: 3) ["100"] 1

2. What would be the output of following code?

(function() {
	var array1 = [];
	var array2 = new Array(100);
	var array3 = new Array(['1',2,'3',4,5.6]);
	console.log(array1);
	console.log(array2);
	console.log(array3);
	console.log(array3.length);
}());
  1. [] [] [Array[5]] 1
  2. [] [undefined × 100] Array[5] 5
  3. [] [] ['1',2,'3',4,5.6] 5
  4. [] [] [Array[5]] 5

Answer: 1) [] [] [Array[5]] 1

3. What would be the output of following code?

(function () {
  var array = new Array('a', 'b', 'c', 'd', 'e');
  array[10] = 'f';
  delete array[10];
  console.log(array.length);
}());
  1. 11
  2. 5
  3. 6
  4. undefined

Answer: 1) 11

4. What would be the output of following code?

(function(){
	var animal = ['cow','horse'];
		animal.push('cat');
		animal.push('dog','rat','goat');
		console.log(animal.length);
})();
  1. 4
  2. 5
  3. 6
  4. undefined

Answer: 3) 6

5. What would be the output of following code?

(function(){
	var animal = ['cow','horse'];
		animal.push('cat');
		animal.unshift('dog','rat','goat');
		console.log(animal);
})();
  1. [ 'dog', 'rat', 'goat', 'cow', 'horse', 'cat' ]
  2. [ 'cow', 'horse', 'cat', 'dog', 'rat', 'goat' ]
  3. Type Error
  4. undefined

Answer: 1) [ 'dog', 'rat', 'goat', 'cow', 'horse', 'cat' ]

6. What would be the output of following code?

(function(){
	var array = [1,2,3,4,5];
	console.log(array.indexOf(2));
	console.log([{name: 'John'},{name : 'John'}].indexOf({name:'John'}));
	console.log([[1],[2],[3],[4]].indexOf([3]));
	console.log("abcdefgh".indexOf('e'));
})();
  1. 1 -1 -1 4
  2. 1 0 -1 4
  3. 1 -1 -1 -1
  4. 1 undefined -1 4

Answer: 1) 1 -1 -1 4

7. What would be the output of following code?

(function(){
	var array = [1,2,3,4,5,1,2,3,4,5,6];
	console.log(array.indexOf(2));
	console.log(array.indexOf(2,3));
	console.log(array.indexOf(2,10));
})();
  1. 1 -1 -1
  2. 1 6 -1
  3. 1 1 -1
  4. 1 undefined undefined

Answer: 2) 1 6 -1

8. What would be the output of following code?

(function(){
	var numbers = [2,3,4,8,9,11,13,12,16];
	var even = numbers.filter(function(element, index){
		return element % 2 === 0;
	});
	console.log(even);

	var containsDivisibleby3 = numbers.some(function(element, index){
		return element % 3 === 0;
	});

	console.log(containsDivisibleby3);
})();
  1. [ 2, 4, 8, 12, 16 ] [ 0, 3, 0, 0, 9, 0, 12]
  2. [ 2, 4, 8, 12, 16 ] [ 3, 9, 12]
  3. [ 2, 4, 8, 12, 16 ] true
  4. [ 2, 4, 8, 12, 16 ] false

Answer: 3) [ 2, 4, 8, 12, 16 ] true

9. What would be the output of following code?

(function(){
	var containers = [2,0,false,"", '12', true];
	var containers = containers.filter(Boolean);
	console.log(containers);
	var containers = containers.filter(Number);
	console.log(containers);
	var containers = containers.filter(String);
	console.log(containers);
	var containers = containers.filter(Object);
	console.log(containers);		
})();
  1. [ 2, '12', true ] [ 2, '12', true ] [ 2, '12', true ] [ 2, '12', true ]
  2. [false, true] [ 2 ] ['12'] [ ]
  3. [2,0,false,"", '12', true] [2,0,false,"", '12', true] [2,0,false,"", '12', true] [2,0,false,"", '12', true]
  4. [ 2, '12', true ] [ 2, '12', true, false ] [ 2, '12', true,false ] [ 2, '12', true,false]

Answer: 1) [ 2, '12', true ] [ 2, '12', true ] [ 2, '12', true ] [ 2, '12', true ]

10. What would be the output of following code?

(function(){
	var list = ['foo','bar','john','ritz'];
	    console.log(list.slice(1));
	    console.log(list.slice(1,3));
	    console.log(list.slice());
	    console.log(list.slice(2,2));
	    console.log(list);				
})();
  1. [ 'bar', 'john', 'ritz' ] [ 'bar', 'john' ] [ 'foo', 'bar', 'john', 'ritz' ] [] [ 'foo', 'bar', 'john', 'ritz' ]
  2. [ 'bar', 'john', 'ritz' ] [ 'bar', 'john','ritz ] [ 'foo', 'bar', 'john', 'ritz' ] [] [ 'foo', 'bar', 'john', 'ritz' ]
  3. [ 'john', 'ritz' ] [ 'bar', 'john' ] [ 'foo', 'bar', 'john', 'ritz' ] [] [ 'foo', 'bar', 'john', 'ritz' ]
  4. [ 'foo' ] [ 'bar', 'john' ] [ 'foo', 'bar', 'john', 'ritz' ] [] [ 'foo', 'bar', 'john', 'ritz' ]

Answer: 1) [ 'bar', 'john', 'ritz' ] [ 'bar', 'john' ] [ 'foo', 'bar', 'john', 'ritz' ] [] [ 'foo', 'bar', 'john', 'ritz' ]

11. What would be the output of following code?

(function(){
	var list = ['foo','bar','john'];
	    console.log(list.splice(1));		
	    console.log(list.splice(1,2));
	    console.log(list);			
})();
  1. [ 'bar', 'john' ] [] [ 'foo' ]
  2. [ 'bar', 'john' ] [] [ 'bar', 'john' ]
  3. [ 'bar', 'john' ] [ 'bar', 'john' ] [ 'bar', 'john' ]
  4. [ 'bar', 'john' ] [] []

Answer: 1. [ 'bar', 'john' ] [] [ 'foo' ]

12. What would be the output of following code?

(function(){
	var arrayNumb = [2, 8, 15, 16, 23, 42];
	arrayNumb.sort();
	console.log(arrayNumb);
})();
  1. [2, 8, 15, 16, 23, 42]
  2. [42, 23, 26, 15, 8, 2]
  3. [ 15, 16, 2, 23, 42, 8 ]
  4. [ 2, 8, 15, 16, 23, 42 ]

Answer: 3. [ 15, 16, 2, 23, 42, 8 ]

Function:

1. What would be the output of following code ?

function funcA(){
	console.log("funcA ", this);
	(function innerFuncA1(){
		console.log("innerFunc1", this);
		(function innerFunA11(){
			console.log("innerFunA11", this);
		})();
	})();
}

console.log(funcA());
  1. funcA Window {...} innerFunc1 Window {...} innerFunA11 Window {...}
  2. undefined
  3. Type Error
  4. ReferenceError: this is not defined

Answer: 1)

2. What would be the output of following code ?

var obj = {
	message: "Hello",
	innerMessage: !(function() {
		console.log(this.message);
	})()
};

console.log(obj.innerMessage);
  1. ReferenceError: this.message is not defined
  2. undefined
  3. Type Error
  4. undefined true

Answer: 4) undefined true

3. What would the output of following code ?

var obj = {
	message: "Hello",
	innerMessage: function() {
		console.log(this.message);
	}
};

console.log(obj.innerMessage());
  1. Hello
  2. undefined
  3. Type Error
  4. ReferenceError: this.message is not defined

Answer: 1) Hello

4. What would the output of following code ?

var obj = {
  message: 'Hello',
  innerMessage: function () {
    (function () {
      console.log(this.message);
    }());
  }
};
console.log(obj.innerMessage());
  1. Type Error
  2. Hello
  3. undefined
  4. ReferenceError: this.message is not defined

Answer: 3) undefined

5. What would the output of following code ?

var obj = {
  message: 'Hello',
  innerMessage: function () {
  	var self = this;
    (function () {
      console.log(self.message);
    }());
  }
};
console.log(obj.innerMessage());
  1. Type Error
  2. 'Hello'
  3. undefined
  4. ReferenceError: self.message is not defined

Answer: 2) 'Hello'

6. What would the output of following code ?

function myFunc(){
	console.log(this.message);
}
myFunc.message = "Hi John";

console.log(myFunc());
  1. Type Error
  2. 'Hi John'
  3. undefined
  4. ReferenceError: this.message is not defined

Answer: 3) undefined

7. What would the output of following code ?

function myFunc(){
	console.log(myFunc.message);
}
myFunc.message = "Hi John";

console.log(myFunc());
  1. Type Error
  2. 'Hi John'
  3. undefined
  4. ReferenceError: this.message is not defined

Answer: 2) 'Hi John'

8. What would the output of following code ?

function myFunc() {
  myFunc.message = 'Hi John';
  console.log(myFunc.message);
}
console.log(myFunc());
  1. Type Error
  2. 'Hi John'
  3. undefined
  4. ReferenceError: this.message is not defined

Answer: 2) 'Hi John'

9. What would the output of following code ?

function myFunc(param1,param2) {
  console.log(myFunc.length);
}
console.log(myFunc());
console.log(myFunc("a","b"));
console.log(myFunc("a","b","c","d"));
  1. 2 2 2
  2. 0 2 4
  3. undefined
  4. ReferenceError

Answer: a) 2 2 2

10. What would the output of following code ?

function myFunc() {
  console.log(arguments.length);
}
console.log(myFunc());
console.log(myFunc("a","b"));
console.log(myFunc("a","b","c","d"));
  1. 2 2 2
  2. 0 2 4
  3. undefined
  4. ReferenceError

Answer: 2) 0 2 4

Object Oriented

1. What would the output of following code ?

function Person(name, age){
	this.name = name || "John";
	this.age = age || 24;
	this.displayName = function(){
		console.log(this.name);
	}
}

Person.name = "John";
Person.displayName = function(){
	console.log(this.name);
}

var person1 = new Person('John');
	person1.displayName();
	Person.displayName();
  1. John Person
  2. John John
  3. John undefined
  4. John John

Answer: 1) John Person

Scopes

1. What would the output of following code ?

function passWordMngr() {
	var password = '12345678';
	this.userName = 'John';
	return {
		pwd: password
	};
}
// Block End
var userInfo = passWordMngr();
console.log(userInfo.pwd);
console.log(userInfo.userName);
  1. 12345678 Window
  2. 12345678 John
  3. 12345678 undefined
  4. undefined undefined

Answer: 3) 12345678 undefined

2. What would the output of following code ?

var employeeId = 'aq123';
function Employee() {
  this.employeeId = 'bq1uy';
}
console.log(Employee.employeeId);
  1. Reference Error
  2. aq123
  3. bq1uy
  4. undefined

Answer: 4) undefined

3. What would the output of following code ?

var employeeId = 'aq123';

function Employee() {
	this.employeeId = 'bq1uy';
}
console.log(new Employee().employeeId);
Employee.prototype.employeeId = 'kj182';
Employee.prototype.JobId = '1BJKSJ';
console.log(new Employee().JobId);
console.log(new Employee().employeeId);
  1. bq1uy 1BJKSJ bq1uy undefined
  2. bq1uy 1BJKSJ bq1uy
  3. bq1uy 1BJKSJ kj182
  4. undefined 1BJKSJ kj182

Answer: 2) bq1uy 1BJKSJ bq1uy

4. What would the output of following code ?

var employeeId = 'aq123';
(function Employee() {
	try {
		throw 'foo123';
	} catch (employeeId) {
		console.log(employeeId);
	}
	console.log(employeeId);
}());
  1. foo123 aq123
  2. foo123 foo123
  3. aq123 aq123
  4. foo123 undefined

Answer: 1) foo123 aq123

Call, Apply, Bind

1. What would the output of following code ?

(function() {
	var greet = 'Hello World';
	var toGreet = [].filter.call(greet, function(element, index) {
		return index > 5;
	});
	console.log(toGreet);
}());
  1. Hello World
  2. undefined
  3. World
  4. [ 'W', 'o', 'r', 'l', 'd' ]

Answer: 4) [ 'W', 'o', 'r', 'l', 'd' ]

2. What would the output of following code ?

(function() {
	var fooAccount = {
		name: 'John',
		amount: 4000,
		deductAmount: function(amount) {
			this.amount -= amount;
			return 'Total amount left in account: ' + this.amount;
		}
	};
	var barAccount = {
		name: 'John',
		amount: 6000
	};
	var withdrawAmountBy = function(totalAmount) {
		return fooAccount.deductAmount.bind(barAccount, totalAmount);
	};
	console.log(withdrawAmountBy(400)());
	console.log(withdrawAmountBy(300)());
}());
  1. Total amount left in account: 5600 Total amount left in account: 5300
  2. undefined undefined
  3. Total amount left in account: 3600 Total amount left in account: 3300
  4. Total amount left in account: 5600 Total amount left in account: 5600

Answer: 1) Total amount left in account: 5600 Total amount left in account: 5300

3. What would the output of following code ?

(function() {
	var fooAccount = {
		name: 'John',
		amount: 4000,
		deductAmount: function(amount) {
			this.amount -= amount;
			return this.amount;
		}
	};
	var barAccount = {
		name: 'John',
		amount: 6000
	};
	var withdrawAmountBy = function(totalAmount) {
		return fooAccount.deductAmount.apply(barAccount, [totalAmount]);
	};
	console.log(withdrawAmountBy(400));
	console.log(withdrawAmountBy(300));
	console.log(withdrawAmountBy(200));
}());
  1. 5600 5300 5100
  2. 3600 3300 3100
  3. 5600 3300 5100
  4. undefined undefined undefined

Answer: 1) 5600 5300 5100

4. What would the output of following code ?

(function() {
	var fooAccount = {
		name: 'John',
		amount: 6000,
		deductAmount: function(amount) {
			this.amount -= amount;
			return this.amount;
		}
	};
	var barAccount = {
		name: 'John',
		amount: 4000
	};
	var withdrawAmountBy = function(totalAmount) {
		return fooAccount.deductAmount.call(barAccount, totalAmount);
	};
	console.log(withdrawAmountBy(400));
	console.log(withdrawAmountBy(300));
	console.log(withdrawAmountBy(200));
}());
  1. 5600 5300 5100
  2. 3600 3300 3100
  3. 5600 3300 5100
  4. undefined undefined undefined

Answer: 2) 3600 3300 3100

5. What would the output of following code ?

(function greetNewCustomer() {
	console.log('Hello ' + this.name);
}.bind({
	name: 'John'
})());
  1. Hello John
  2. Reference Error
  3. Window
  4. undefined

Answer: 1) Hello John

6. Suggest your question!

Callback Function

1. What would the output of following code ?

function getDataFromServer(apiUrl){
    var name = "John";
	return {
		then : function(fn){
			fn(name);
		}
	}
}

getDataFromServer('www.google.com').then(function(name){
	console.log(name);
});
  1. John
  2. undefined
  3. Reference Error
  4. fn is not defined

Answer: 1) John

2. What would the output of following code ?

(function(){
	var arrayNumb = [2, 8, 15, 16, 23, 42];
	Array.prototype.sort = function(a,b){
		return a - b;
	};
	arrayNumb.sort();
	console.log(arrayNumb);
})();

(function(){
	var numberArray = [2, 8, 15, 16, 23, 42];
	numberArray.sort(function(a,b){
		if(a == b){
			return 0;
		}else{
			return a < b ? -1 : 1;
		}
	});
	console.log(numberArray);
})();

(function(){
	var numberArray = [2, 8, 15, 16, 23, 42];
	numberArray.sort(function(a,b){
		return a-b;
	});
	console.log(numberArray);
})();
  1. [ 2, 8, 15, 16, 23, 42 ] [ 2, 8, 15, 16, 23, 42 ] [ 2, 8, 15, 16, 23, 42 ]
  2. undefined undefined undefined
  3. [42, 23, 16, 15, 8, 2] [42, 23, 16, 15, 8, 2] [42, 23, 16, 15, 8, 2]
  4. Reference Error

Answer: 1) [ 2, 8, 15, 16, 23, 42 ] [ 2, 8, 15, 16, 23, 42 ] [ 2, 8, 15, 16, 23, 42 ]

Return Statement

1. What would the output of following code ?

(function(){
	function sayHello(){
		var name = "Hi John";
		return
		{
			fullName: name
		}
	}
	console.log(sayHello().fullName);
})();
  1. Hi John
  2. undefined
  3. Reference Error
  4. Uncaught TypeError: Cannot read property 'fullName' of undefined

Answer: 4) Uncaught TypeError: Cannot read property 'fullName' of undefined

2. What would the output of following code ?

function getNumber(){
	return (2,4,5);
}

var numb = getNumber();
console.log(numb);
  1. 5
  2. undefined
  3. 2
  4. (2,4,5)

Answer: 1) 5

3. What would the output of following code ?

function getNumber(){
	return;
}

var numb = getNumber();
console.log(numb);
  1. null
  2. undefined
  3. ""
  4. 0

Answer: 2) undefined

4**. What would the output of following code ?

function mul(x){
	return function(y){
		return [x*y, function(z){
			return x*y + z;
		}];
	}
}

console.log(mul(2)(3)[0]);
console.log(mul(2)(3)[1](4));
  1. 6, 10
  2. undefined undefined
  3. Reference Error
  4. 10, 6

Answer: 1) 6, 10

5**. What would the output of following code ?

function mul(x) {
	return function(y) {
		return {
			result: x * y,
			sum: function(z) {
				return x * y + z;
			}
		};
	};
}
console.log(mul(2)(3).result);
console.log(mul(2)(3).sum(4));
  1. 6, 10
  2. undefined undefined
  3. Reference Error
  4. 10, 6

Answer: 1) 6, 10

6. What would the output of following code ?

function mul(x) {
	return function(y) {
		return function(z) {
			return function(w) {
				return function(p) {
					return x * y * z * w * p;
				};
			};
		};
	};
}
console.log(mul(2)(3)(4)(5)(6));
  1. 720
  2. undefined
  3. Reference Error
  4. Type Error

Answer: 1) 720