Q.1 Define primitive, non primitive and composite data types. Give examples of each.
(6M)
Q.2 What does it mean in JavaScript when something is displayed as “undefined” in the console? How
is it different from “null”. (4M)
Q.3 Find all the bugs in this JavaScript code: (4M)
var msg ="Welcome to JavaScript ...';
var tempvar ="false";
var $punchline= "Hello." //semicolon reqd
var %entage=20;
if(tempvar=true){ // “==” reqd
Alert($punchline); }
else //{ bracket reqd
alert(msg);
Q.4 What is the difference between Literal, variables and constant. Explain with example.
Q. 5 What are the rules for naming a JavaScript variable? Give example of an invalid variable name.
(5M)
Q. 6 List different operators supported by JS. (4M)
Given a JS statement
y = 5 + "10 years";
document.write( y, "<br>"); w
What will be the output?
Q. 7 What are the limitations of switch statement? Rewrite the following code using if…else if statement.
(6M)
switch (direction)
case “N” : a = “North”; break;
case “E” : a = “East”; break;
case “W” : a
Q. 7 Evaluate the following arithmetic expression and find out its output, assuming b = 4 and c = 4.
a=b*3/ 4+c/ 4+8—b +5/8 (4M)
Q. 8 Enlist features of Java script. What is the difference between Java & JavaScript? (6M)
Q. 9 How can you create an Array of 5 integers in JavaScript? (2M)
Q. 10 What are the scopes of a variable in JavaScript? (4M)
Q. 11 What is the purpose of ‘This’ operator in JavaScript? (4M)
Q. 12 How does TypeOf Operator work? (6M)
For a given JS code What will be output of each print statement.
var v1; console.log('type:' + typeof v1);
v1 = 'abc'; console.log('type:' + typeof v1);
v1 = '123'; console.log('type:' + typeof v1);
v1 = 123; console.log('type:' + typeof v1);
v1 = false; console.log('type:' + typeof v1)
v1 = null; console.log('type:' + typeof v1);
v1 = { name:'peter', age:21 }; console.log('type:' + typeof v1);
Q. 14 What is NaN in JavaScript? (4M)
Q. 15 How can you convert the string of any base to integer in JavaScript? Write an expression in JS to
convert “ABC” to an integer. (4M)
Q. 16 What are escape characters in JavaScript? (4M)
Q. 17 What are undeclared and undefined variables? (4M)
Q. 18 Differentiate between operators - Sign Propagating Right Shift and Zero fill Right Shift.
(6M)
For the given JS code
:
var a = 6;
var b = 1;
//Sign Propagating Right Shift
document.write("A >> B = " + (a >> b) + '<br>');
// Zero Fill Right Shift
document.write("A >>> B = " + (a >>> b) + '<br>');
What is the output ?
Programs:
Q. Write a Javascript to find factorial of a number. Write the script in HTML Code.. Give heading to your
code (6M)x
Q. Write a JS code to reverse the string and confirm whether a palindrome. Accept the string from
keyboard.
Q. Display multiplication table of user defined number in the browser as well as console.
Q. On a “Submit” button click display “OK” in broser.