JavaScript Questions

0 votes, 0 avg
649

JavaScript Questions

1 / 15

1. What is the use of the noscript tag in Javascript?

2 / 15

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

3 / 15

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

4 / 15

4. 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");
}

5 / 15

5. Which JavaScript method is used to write into an alert box?

6 / 15

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

const arr = [10, 20, 30];
 let result = 0;
 
 arr.forEach(myFunction);
 
 document.write("Result: " , result)
 function myFunction(value, index, array) {
   result += value; 
 }

7 / 15

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

var cars = ["Honda","Hyundai","Mahindra"];
 
 var result = cars.shift();
 
 document.writeln("Result: ", cars);

8 / 15

8. 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);

9 / 15

9. Which one of the following is correct output for the following given JavaScript code if there is a p tag with id=demo ?
functionourFunction()
{
document.getElementById("demo").innerHTML=Math.abs(-7.25);
}

10 / 15

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

let sum = 0; 
const a = [1, 2, 3];
a.forEach(getSum);
print(sum);
function getSum(ele) {
   sum += ele;
}

11 / 15

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

const obj1 = {Name: "Hello", Age: 16};
const obj2 = {Name: "Hello", Age: 16};
print(obj1 === obj2);

12 / 15

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

// Javascript code to compare the height
function height()
{ 
    var  height = 123.56;
    var type = (height>=190) ? "tall" : "short";
    return type;
}

13 / 15

13. Which handler is triggered when the content of the document in the window is stable and ready for manipulation?

14 / 15

14. What is the prototype represents in the following JavaScript code snippet?

 function javascript() 
{};

15 / 15

15. Any time you include javascript variable in HTML document, you must enclose those lines inside a _______

Your score is

0%

Written by Shubhranshu Shekhar, who has trained 20000+ students in coding.

Scroll to Top