JavaScript Questions

0 votes, 0 avg
474

JavaScript Questions

1 / 15

1. In JavaScript, what is a block of statement?

2 / 15

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

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

3 / 15

3. The “function” and ” var” are known as:

4 / 15

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

const prototype1 = {};  
const object1 = Object.create(prototype1);  
console.log(Object.getPrototypeOf(object1) === prototype1);

5 / 15

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

let x = "10";
    let y = + x;
    
    document.write(typeof y);

6 / 15

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

7 / 15

7.  Where is Client-side JavaScript code is embedded within HTML documents?

8 / 15

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

var a = 1;  
var b = 0;  
while (a <= 3)  
{  
   a++;  
   b += a * 2;  
   print(b);
}

9 / 15

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


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

10 / 15

10.  If A is the superclass and B is the subclass, then subclass inheriting the superclass can be represented as _________

11 / 15

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

12 / 15

12. Which is the correct syntax to call an external JavaScript file in the current HTML document?

13 / 15

13. 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; 
 }

14 / 15

14. Which of the following is not considered as an error in javascript?

15 / 15

15.  What will be the function of the following JavaScript program?

var scope = "js scope";
function checkscope() 
{
    var scope = "javascript scope"; 
    function f() 
    { 
         return scope; 
    }
    return f;
}