ProFlemingo

JAVASCIPT Questions:

1. What is JavaScript?
a) JavaScript is a scripting language used to make the website interactive
b) JavaScript is an assembly language used to make the website interactive
c) JavaScript is a compiled language used to make the website interactive
d) None of the mentioned
2. Which of the following is correct about JavaScript?
a) JavaScript is an Object-Based language
b) JavaScript is Assembly-language
c) JavaScript is an Object-Oriented language
d) JavaScript is a High-level language
3. Among the given statements, which statement defines closures in JavaScript?
a) JavaScript is a function that is enclosed with references to its inner function scope
b) JavaScript is a function that is enclosed with references to its lexical environment
c) JavaScript is a function that is enclosed with the object to its inner function scope
d) None of the mentioned
4. What will be the output of the following JavaScript code snippet?
p id="demo"
var txt1 = "Sanfoundry_";
var txt2 = "Javascriptmcq";
document.getElementById("demo").innerHTML = txt1 + txt2;
a) error
b) Sanfoundry_ Javascriptmcq
c) undefined
d) Sanfoundry_Javascriptmct
5. What will be the output of the following JavaScript code?
p id="demo"
script
var js = 10;
js *= 5;
document.getElementById("demo").innerHTML = js;
script
a) 10
b) 50
c) 5
d) Error
6. Arrays in JavaScript are defined by which of the following statements?
a) It is an ordered list of values
b) It is an ordered list of objects
c) It is an ordered list of string
d) It is an ordered list of functions
7. What will be the output of the following JavaScript code?
// JavaScript Comparison Operators
function compare()
{
    int num=2;
    char b=2;
    if(a==b)
        return true;
    else
        return false;
}
a) false
b) true
c) compilation error
d) runtime error
8. What will be the output of the following JavaScript code snippet?

// JavaScript Equalto Operators
function equalto()
{
    int num=10;
    if(num==="10")
        return true;
    else
        return false;
}
a) false
b) true
c) compilation error
d) runtime error
9. Will the following JavaScript code work?

var js = (function(x) {return x*x;}(10));
a) Exception will be thrown
b) Memory leak
c) Error
d) Yes, perfectly
10. Which of the following is not javascript data types?
a) Null type
b) Undefined type
c) Number type
d) All of the mentioned
11. Where is Client-side JavaScript code is embedded within HTML documents?
a) A URL that uses the special javascript:code
b) A URL that uses the special javascript:protocol
c) A URL that uses the special javascript:encoding
d) A URL that uses the special javascript:stack
12. What will be the output of the following JavaScript code snippet?
int a=1;
if(a!=null) // JavaScript not equal to Operators
    return 1;
else
    return 0;
a) 0
b) 1
c) compiler error
d) runtime error
13. Which of the following object is the main entry point to all client-side JavaScript features and APIs?
a) Position
b) Window
c) Standard
d) Location
14. What will be the output of the following JavaScript program?
function sanfoundry(javascript)
{
	return (javascript ?  “yes” :  “no”);
}
	bool ans=true;
console.log(sanfoundry(ans));
unction sanfoundry(javascript)
{
	return (javascript ?  “yes” :  “no”);
}
	bool ans=true;
console.log(sanfoundry(ans));
a) Compilation error
b) Runtime error
c) Yes
d) No
15. What will be the output of the following JavaScript code?
// Javascript code snippet to compare the height
function height(){	
    var  height = 123.56;
    var type = (height>=190) ? "tall" : "short";
    return type;
}
a) short
b) 123.56
c) tall
d) 190