JavaScript Questions

0 votes, 0 avg
608

JavaScript Questions

1 / 15

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

function printArray(a) 
{
     var len = a.length, i = 0;
     if (len == 0)
        console.log("Empty Array");
     else 
     {
// do-while loop in javascript
         do 
         {
             console.log(a[i]);
         } while (++i < len);
     }
}

2 / 15

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


var a = "Scaler";
var result = a.substring(2, 4);
document.write(result);

3 / 15

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

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

4 / 15

4. What will be the output of the following JavaScript code with a p tag with id=demo?

function myFunction() 
{
    document.getElementById("demo").innerHTML = Math.atan2(8, 4);
}

5 / 15

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

6 / 15

6. Which of the following is correct about JavaScript?

7 / 15

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

function solve(arr, rotations){
 if(rotations == 0) return arr;
 for(let i = 0; i < rotations; i++){
   let element = arr.pop();
   arr.unshift(element);
 }
 return arr;
}
// solve([44, 1, 22, 111], 5);

8 / 15

8. What is the code for getting the current time?

9 / 15

9.  Which of the following can be implemented using animation?

10 / 15

10. JavaScript code can be written in ____.

11 / 15

11. Which is the correct syntax for the function definition?

12 / 15

12. Which JavaScript method is used to write HTML output?

13 / 15

13. Which statement creates a new object using the Person constructor?

14 / 15

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

  let cars = ['Honda', 'Hyundai'];
    cars.push('Mahindra');
    document.write(typeof cars + " " + cars); 

15 / 15

15. What does the ‘toLocateString()’ method do in JS?

Your score is

0%