What is JavaScript?
JavaScript is a client-side scripting language that can be inserted into HTML pages and is understood by web browsers.
Enumerate the differences between Java and JavaScript?
Java is a complete programming language. In contrast, JavaScript is a coded program that can be introduced to HTML pages. These two languages are not at all inter-dependent and are designed for the different intent.  Java is an object – oriented programming (OOPS) or structured programming language like C++ or C whereas JavaScript is a client-side scripting language and it is said to be unstructured programming.
What are JavaScript types?
Following are the JavaScript types:
What is the use of isNaN function?
isNan function returns true if the argument is not a number otherwise it is false.
Between JavaScript and an ASP script, which is faster?
JavaScript is faster. JavaScript is a client-side language and thus it does not need the assistance of the web server to execute. On the other hand, ASP is a server-side language and hence is always slower than JavaScript.
What is negative infinity?
Negative Infinity is a number in JavaScript which can be derived by dividing negative number by zero.
Is it possible to break JavaScript Code into several lines?
Breaking within a string statement can be done by the use of a backslash, ‘\’, at the end of the first line
document.write("This is \a program");
And if you change to a new line when not within a string statement, then javaScript ignores break in line.
var x=1, y=2,
The above code is perfectly fine, though not advisable as it hampers debugging.
Which company developed JavaScript?
Netscape is the software company who developed JavaScript.
What are undeclared and undefined variables?
Undeclared variables are those that do not exist in a program and are not declared. If the program tries to read the value of an undeclared variable, then a runtime error is encountered.
Undefined variables are those that are declared in the program but have not been given any value. If the program tries to read the value of an undefined variable, an undefined value is returned.
Write the code for adding new elements dynamically?
<head> <title>t1</title>
<script type="text/javascript">
function addNode() { var newP = document.createElement("p");
var textNode = document.createTextNode(" This is a new text node");
newP.appendChild(textNode); document.getElementById("firstP").appendChild(newP); }
</script> </head>
<body> <p id="firstP">firstP<p> </body>
What are global variables? How are these variable declared and what are the problems associated with using them?
Global variables are those that are available throughout the length of the code, that is, these have no scope. The var keyword is used to declare a local variable or object. If the var keyword is omitted, a global variable is declared.
// Declare a global globalVariable = “Test”;
The problems that are faced by using global variables are the clash of variable names of local and global scope. Also, it is difficult to debug and test the code that relies on global variables.
What is a prompt box?
A prompt box is a box which allows the user to enter input by providing a text box.  Label and box will be provided to enter the text or number.
What is ‘this’ keyword in JavaScript?
‘This’ keyword is used to point at the current object in the code. For instance: If the code is presently at an object created by the help of the ‘new’ keyword, then ‘this’ keyword will point to the object being created.
Explain the working of timers in JavaScript? Also elucidate the drawbacks of using the timer, if any?
Timers are used to execute a piece of code at a set time or also to repeat the code in a given interval of time. This is done by using the functions setTimeout, setInterval and clearInterval.
The setTimeout(function, delay) function is used to start a timer that calls a particular function after the mentioned delay. The setInterval(function, delay) function is used to repeatedly execute the given function in the mentioned delay and only halts when cancelled. The clearInterval(id) function instructs the timer to stop.
Timers are operated within a single thread, and thus events might queue up, waiting to be executed.
Which symbol is used for comments in Javascript?
// for Single line comments and
/*   Multi
What is the difference between ViewState and SessionState?
‘ViewState’ is specific to a page in a session.
‘SessionState’ is specific to user specific data that can be accessed across all pages in the web application.
What is === operator?
=== is called as strict equality operator which returns true when the two operands are having the same value without any type conversion.
Explain how can you submit a form using JavaScript?
To submit a form using JavaScript use document.form[0].submit();
Does JavaScript support automatic type conversion?
Yes JavaScript does support automatic type conversion, it is the common way of type conversion used by JavaScript developers
How can the style/class of an element be changed?
It can be done in the following way:
document.getElementById(“myText”).style.fontSize = “20?;
document.getElementById(“myText”).className = “anyclass”;
Explain how to read and write a file using JavaScript?
There are two ways to read and write a file using JavaScript
             Using JavaScript extensions
             Using a web page and Active X objects
What are all the looping structures in JavaScript?
Following are looping structures in Javascript:
             do-while loops
What is called Variable typing in Javascript?
Variable typing is used to assign a number to a variable and the same variable can be assigned to a string.
i = 10;
i = "string";
This is called variable typing.
How can you convert the string of any base to integer in JavaScript?
The parseInt() function is used to convert numbers between different bases. parseInt() takes the string to be converted as its first parameter, and the second parameter is the base of the given string.
In order to convert 4F (of base 16) to integer, the code used will be –
parseInt ("4F", 16);
Explain the difference between “==” and “===”?
“==” checks only for equality in value whereas “===” is a stricter equality test and returns false if either the value or the type of the two variables are different.
What would be the result of 3+2+”7″?
Since 3 and 2 are integers, they will be added numerically. And since 7 is a string, its concatenation will be done. So the result would be 57.
Explain how to detect the operating system on the client machine?
In order to detect the operating system on the client machine, the navigator.appVersion string (property) should be used.
What do mean by NULL in Javascript?
The NULL value is used to represent no value or no object.  It implies no object or null string, no valid boolean value, no number and no array object.
What is the function of delete operator?
The functionality of delete operator is used to delete all variables and objects in a program but it cannot delete variables declared with VAR keyword.
What is an undefined value in JavaScript?
Undefined value means the
             Variable used in the code doesn’t exist
             Variable is not assigned to any value
             Property doesn’t exist
What is the ‘Strict’ mode in JavaScript and how can it be enabled?
             Strict Mode adds certain compulsions to JavaScript. Under the strict mode, JavaScript shows errors for a piece of codes, which did not show an error before, but might be problematic and potentially unsafe. Strict mode also solves some mistakes that hamper the JavaScript engines to work efficiently.
             Strict mode can be enabled by adding the string literal “use strict” above the file. This can be illustrated by the given example:
function myfunction()
“use strict";
var v = “This is a strict mode function";
What is the way to get the status of a Check Box?
The status can be acquired as follows –
             If the CheckBox will be checked, this alert will return TRUE.
How can the OS of the client machine be detected?
The navigator.appVersion string can be used to detect the operating system on the client machine.
Explain window.onload and on Document Ready?
             The on load function is not run until all the information on the page is loaded. This leads to a substantial delay before any code is executed.
             On Document Ready loads the code just after the DOM is loaded. This allows early manipulation of the code.
How will you explain closures in JavaScript? When are they used?
             Closure is a locally declared variable related to a function which stays in memory when the function has returned.
For example:
function greet(message) {
function greeter(name, age) {
return name + " says howdy!! He is " + age + " years old";
// Generate the message
var message = greeter("James", 23);
// Pass it explicitly to greet
This function can be better represented by using closures
function greeter(name, age) {
var message = name + " says howdy!! He is " + age + " years old";
return function greet() {
// Generate the closure
var JamesGreeter = greeter("James", 23);
// Use the closure

Request to Download PDF

Post A Comment: