0% found this document useful (0 votes)
13 views17 pages

Ut 1

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views17 pages

Ut 1

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

BHARATI VIDYAPEETH INSTITUTE OF TECHNOLOGY

QUESTION BANK
Unit Test-I (Shift:-I & II)
Program : - Computer Engineering Group Program Code:- CM/IF
Course Title: -Client Side Scripting Language Semester: - Fifth
Course Abbr &Code:-CSS (22519) Scheme:

I --
------------------------------------------------------------------------------------------------

CHAPTER-1 (Basics of JavaScript Programming) (CO1)

2 MARKS

1.Explain any two features of JavaScript.


ANS

.
2. Compare client-side and server-side scripting.

PARAMETERS CLIENT SIDE SERVER SIDE


SCRIPTING SCRIPTING
DEFINATION It is executed on the client It is executed on the
side so it is called client side server side so it is called
scripting server side scripting
BASIC Used to develop the front end Used to develop the core
which can be seen or functionality of the
interacted with by the user product and is usually
hidden from the end user
IMPACTS It can be used to reduce the Allows the website to be
server loads dynamic than static
SECURITY No security measures used Relatively secure

LANGUAGES HTML, CSS , JavaScript\ PHP, Ruby ,ASP.NET,


USED Python

3. List types of operators in JavaScript.


There are 6 types of operators on java
1.Arithmetic operators
2.Logical operators
3.Conditional operators
4.Bitwise operators
5.Assignment operators
6.Comparison operators
4 MARKS

1. Explain six types of values in JavaScript.


Here are six fundamental types of values in JavaScript:
1.Number
Description: Represents both integer and floating-point numbers.
JavaScript does not distinguish between integer and floating-point
numbers; all are treated as `Number` type.
- Examples
var a = 42;
var b = 3.14;
2. String
Represents a sequence of characters used for textual data. Strings are
enclosed in single quotes (`'`), double quotes (`"`), or backticks (`` ` ``)
for template literals.
- Examples :
var name = "Alice";
var greeting = 'Hello, world!';
var templateLiteral = `Hello, ${name}`;
3. Boolean
Represents a logical entity and can have only one of two values:
`true` or `false`.
- Examples :
var isJavaScriptFun = true;
var isSkyBlue = false;
4. Undefined
A variable that has been declared but not assigned a value is of type
`undefined`.
- Examples :
var x;
5. Null
Represents the intentional absence of any object value. It is often
used to indicate that a variable should have no value.
- Examples :
var y = null;

2. Compare client-side and server-side scripting.


criteria CLIENT SIDE SERVER SIDE
SCRIPTING SCRIPTING
DEFINATION It is executed on the client It is executed on the
side so it is called client side server side so it is called
scripting server side scripting
BASIC Used to develop the front end Used to develop the core
which can be seen or functionality of the
interacted with by the user product and is usually
hidden from the end user
IMPACTS It can be used to reduce the Allows the website to be
server loads dynamic than static
SECURITY No security measures used Relatively secure

LANGUAGES PHP, Ruby ,ASP.NET, HTML, CSS , JavaScript


USED Python
3. Write a JavaScript program to display squares of 1 to
10 numbers using while loop.
<!DOCTYPE html>
<html lang="en">
<head>

<title>Document</title>
</head>
<body>
<script>
var num = 1;
while (num <= 10)
{
var sq = num * num;
document.write("The square of "+num+" is "+sq+ "<br>");
num++;
}
</script>
</body>
</html>

4. Write a JavaScript program to generate Armstrong


number between 1 to 100.
CHAPTER-2 (Array, Function and String) (CO2)
2 MARKS

1. Write syntax for defining the function.


We can write functions with and without arguments
Syntax for function without arguments :
<script>
Function function_name();
{
Statements
}
</script>
Syntax for function with arguments :
<script>
Function function_name(arguments);
{
Statements
}
</script>

2. Write a JavaScript to reverse the elements of array.


<!DOCTYPE html>
<html lang="en">
<head>
<title>Document</title>
</head>
<body>
<script>
var a = new Array();
a[0]="b";
a[1]="a";
a[2]="e";
a[3]="d";
a[4]="f";

document.write("reverse:"+a.reverse());
</script>
</body>
</html>

3. Explain the use of push and pop functions.


POP()
POP() method is used to remove an item from the end of array and
pop returns the remove
element
It also changes the length of the arry
The syntax is
arrayObject.pop()

PUSH()
PUSH() method is used to add a new element at the end of an array
It is changes the length of the array
The syntax is
arrayObject.push(“shiv”)
4. Define string? How to declare it?
String Represents a sequence of characters used for textual data.
Strings are enclosed in single quotes (`'`), double quotes (`"`), or
backticks (`` ` ``) for template literals.
String is an object that is used for storing and manipulating data
- Examples of declaring a string
var name = "Alice";
var greeting = 'Hello, world!';
var templateLiteral = `Hello, ${name}`;

5. List methods used for finding a Unicode of a character?


4 MARKS

1. Explain the method of calling a function from HTML.


A function can be called from HTML code on your web page. Now
rather than explicitly calling a function, it will be called in response to
an event, such as when the web page is loaded or unloaded by the
browser.
For example:
you have written two different functions named as welcome() and
goodbye() and you want the code of welcome function should executed
when a html form body is loaded in browser and you want goodbye
function should executed when a html form body is unloaded in
browser.
For this code will look like as follows:
<body onload = "welcome()">
<body onunload "goodbye()">
OR
<body onload= "welcome()" onunload "goodbye()">

2. Write a JavaScript to convert a string to number.


------
3. Explain the scope of variable with the help of
programming example.
The scope of a variable means how the different parts of the program
can access that variable.
The extent to which a variable is accessible is called its "scope" and is
determined by where the variable is declared.
A variable declared inside a function block is only accessible to code
within that same function block.
A variable declared outside all function blocks is accessible to code
within any function block.
In JavaScript there are two types of scope namely, Local scope and
Global scope.
LOCAL :
A variable can be declared within a function which is called a local
variable, because the variable is local to the function
GLOBAL:
A variable can be declared outside a function which is called a global
variable, because it is available to all parts of your JavaScript.
Local variables are generally preferable to global variables as their
limited scope prevents possible accidental conflict with other variables.
4. How to initialize an array? Explain with example
Sometimes declaration and initialization step can be combined together
to reduce programming efforts.
While initializing array with declaration then all elements must specified
in parenthesis and elements should be separated by a comma.
arrays can be initialized in several ways. Here are some common
methods:
1. Array Literal
You can use an array literal to initialize an array with predefined values:
var items = new Array("One", "Two", "Three");
2. Array object
Once an array is declare we can define its elements as follows:
var items= new Array(3);
items[0] = "One";
items[1] = "Two";
items[2] = "Three";

5. How to add and sort elements in array? Explain with


example.
• Sorting elements in array.
Sometimes we want elements to appear in sorted order, which means
that strings will be presented alphabetically and numbers will be
displayed in ascending order.
The elements of an array can be displayed in sorted order by calling the
sort() method of the array object.
The syntax is
arrayObject.sort()
• Adding element in array
We can add elements into array by following ways:
1. Using Push method of array.
2. Using Length Property of array.
The push() method adds a new item to the end of an array and returns
the new length of an array. The push() method changes the length of the
array or collection.
The syntax is:
arrayObj.push(elementi, element2, elementN)
If you want to add items at the beginning of an array, then use the
javascript unshift() method. The value of the length property of an array
can be used as the index for the new array element.
Example
<html>
<head>
<title> Array </title>
</head>
<body>
<script>
var arr1 = new Array(3);
arr1[0] = "One";
arr1[1] = "Two";
arr1[2] "Three";
arr1[3] = "Four";
arr.push("Five");
arr1.push("Six", "Seven");
arr1.unshift("Zero");
var arr2 = [41,71,30,42,56,87]
document.write("Before sorting arr11="+ arr1);
document.write("<br>After sorting arr11="+ arr1.sort());
document.write("<br>Before sorting arr2="+ arr2);
document.write("<br>After sorting arr2="+arr2.sort(function(a,b){return
a-b)));
</script>
</body>
</html>

CHAPTER-3 (Form and Event Handling) (CO3)


2 MARKS
1. Explain two uses of forms.
2. How will you create password field in a HTML form.

3. Describe the use of read only element in JavaScript?

4 MARKS
Describe the term intrinsic functions in detail.
2. How to evaluate checkbox selections? Describe with
example..
3. Design a HTML form for filling the information for
registration of a student.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<title>form</title>
<link rel="stylesheet" href="./user.css">
</head>
<body>
<h1>html forms</h1>
<hr>
<br>
<form action="#"method="get">
First Name<input type="text" name="fname" id="fname" required>
<br>
Contact <input type="tel" name="contact" id="contact">
<br>
Number <input type="number" name="favnum" id="favnum">
Enter email <input type="email" name="email" id="email">
<br>
<br>
<input type="checkbox" name="female" id="female"
value="FEMALE">
<input type="checkbox" name="male” id="male"
value="MALE">
</form>
</body>
</html>
4. How to change labels dynamically? Explain with
example.
5. With the help of example describe how to change
option list dynamically.

You might also like