JavaScript Questions

0 votes, 0 avg
1

JavaScript Questions

1 / 15

1. What will be the output of the following JavaScript code If these is a p tag element with id=”demo”?

var numbers1 = [4, 9];
var numbers2 = numbers1.map(myFunction);
document.getElementById("demo").innerHTML = numbers2;
function myFunction(value, index, array)
{
return value * 2;
}

2 / 15

2. The correct syntax to write “Hello World” in javascript.

3 / 15

3. Which of the following function of the String object returns the character in the string starting at the specified position via the specified number of characters?

4 / 15

4. Will the following JavaScript code work?

var js = (function(x) {return x*x;}(10));

5 / 15

5. Which is the function used to call a function in every time duration?

6 / 15

6. What will be the output of the following code snippet?

a = [1, 2, 3, 4, 5];
print(a.slice(2, 4));

7 / 15

7. Which collection object allows unique value to be inserted only once?

8 / 15

8. Arrays in JavaScript are defined by which of the following statements?

9 / 15

9. What will be the output of the following JavaScript code?

const curr = new Date();
 document.write(curr);

10 / 15

10. How are windows, tabs, iframes, and frames treated according to client-side javascript?

11 / 15

11. What will be the output of the following code snippet?

let a = [1, 2, 3, 4, 5, 6];
var left = 0, right = 5;
var found = false;
var target = 5;
while(left <= right) {
   var mid = Math.floor((left + right) / 2);
   if(a[mid] == target) {
       found = true;
       break;
   }
   else if(a[mid] < target) {
       left = mid + 1;
   }
   else {
       right = mid - 1;
   }
}
if(found) {
   print("YES");
}
else {
   print("NO");
}

12 / 15

12. how can you write into HTML output using javascript?

13 / 15

13. What is the central concept of JavaScript memory management?

14 / 15

14. Which object in Javascript doesn’t have a prototype?

15 / 15

15. What will be the output of the following JavaScript code?

var quiz=[1,2,3];
var js=[6,7,8];
var result=quiz.concat(js);
document.writeln(result);