JavaScript Interview Questions (Part-2)

learn kro favicon img

1. The following recursive code will cause a stack overflow if the array list is too large. How can you fix this and still retain the recursive pattern? var list = readHugeList();var nextListItem = function() { var item = list.pop(); if (item) { // process the list item… nextListItem(); }}; Answer:The potential stack overflow can … Read more

JavaScript Interview Questions (Part-1)

learn kro favicon img

1. difference between Function.prototype.apply and Function.prototype.call? The only difference between apply and call is how we pass the arguments in the function being called. In apply we pass the arguments as an array and in call we pass the arguments directly in the argument list. Example: const obj1 = {result:0}; const obj2 = {result:0}; function … Read more

10 Days of JavaScript HackerRank Challenges

learn kro favicon img

Solve 10 Days of JavaScript HackerRank Problems Today we’ve solved several JavaScript coding interview problems from hackerrank.com. Here we’ve presented 10 of them. 1. Functions Problem:Implement a function named factorial that has one parameter: an integer, . It must return the value of (i.e., factorial). Solution: 2. Let and Const Problem:1. Declare a constant variable, PI, and … Read more