What Is Java Script
What Is Java Script
What Is Java Script
Number
String
Boolean
Object
Undefined
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.
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.
Timers are operated within a single thread, and thus events might queue up,
waiting to be executed.
'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.
document.form[0].submit();
Does JavaScript support automatic type conversion?
Yes
document.getElementById("myText").style.fontSize = "20?;
or
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
Variable typing is used to assign a number to a variable and the same variable
can be assigned to a string.
Example
i = 10;
i = "string";
How can you convert the string of any base to integer in JavaScript?
he 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 -
"==" 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.
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.
the delete keyword is used to delete the property as well as its value.
Example
Alert
Confirm and
Prompt
What is the use of Void(0)?
Example:
The pop() method is similar as the shift() method but the difference is
that the Shift method works at the start of the array. Also the pop()
method take the last element off of the given array and returns it. The
array on which is called is then altered.
The pop() method is similar as the shift() method but the difference is
that the Shift method works at the start of the array. Also the pop()
method take the last element off of the given array and returns it. The
array on which is called is then altered.
Example:
No. JavaScript does not have concept level scope. The variable declared
inside the function has scope inside the function.
They are as –
Primitive
Reference types.
Primitive types are number and Boolean data types. Reference types are
more complex types like strings and dates.
Try{
Code
}
Catch(exp){
Code to throw an exception
}
Finally{
Code runs either it finishes successfully or after catch
}
Which keyword is used to print the text in the screen?
Blur function is used to remove the focus from the specified object.
Load time errors: Errors which come up when loading a web page like
improper syntax errors are known as Load time errors and it generates
the errors dynamically.
Run time errors: Errors that come due to misuse of the command
inside the HTML language.
Logical Errors: These are the errors that occur due to the bad logic
performed on a function which is having different operation.
What is the use of Push method in JavaScript?
The push method is used to add or append one or more elements to the
end of an Array. Using this method, we can append multiple elements by
passing multiple arguments
Unshift method is like push method which works at the beginning of the
array. This method is used to prepend one or more elements to the
beginning of the array.
obj.class = 12;
function myfunction() {
"use strict";
var v = "This is a strict mode function";
}
The onload function is not run until all the information on the page is loaded.
This leads to a substantial delay before any code is executed.
onDocumentReady loads the code just after the DOM is loaded. This allows
early manipulation of the code
he function .call() and .apply() are very similar in their usage except a little
difference. .call() is used when the number of the function's arguments are
known to the programmer, as they have to be mentioned as arguments in the
call statement. On the other hand, .apply() is used when the number is not
known. The function .apply() expects the argument to be an array.
The basic difference between .call() and .apply() is in the way arguments are
passed to the function. Their usage can be illustrated by the given example.
The 'And' Operator (&&), 'Or' Operator (||) and the 'Not' Operator (!) can be
used in JavaScript.
This can be done by including the name of the required frame in the hyperlink
using the 'target' attribute.
Both web-garden and web-farm are web hosting systems. The only difference
is that web-garden is a setup that includes many processors in a single server
while web-farm is a larger setup that uses more than one server.
fh = fopen(getScriptPath(), 0);
DOM stands for Document Object Model and is responsible for how various
objects in a document interact with each other. DOM is required for
developing web pages, which includes objects like paragraph, links, etc.
These objects can be operated to include actions like add or delete. DOM is
also required to add extra capabilities to a web page. On top of that, the use
of API gives an advantage over other existing models.
How are event handlers utilized in JavaScript?
Events are the actions that result from activities, such as clicking a link or
filling a form, by the user. An event handler is required to manage proper
execution of all these events. Event handlers are an extra attribute of the
object. This attribute includes event's name and the action taken if the event
takes place
By default, the parsing of the HTML code, during page loading, is paused until
the script has not stopped executing. It means, if the server is slow or the
script is particularly heavy, then the webpage is displayed with a delay. While
using Deferred, scripts delays execution of the script till the time HTML parser
is running. This reduces the loading time of web pages and they get displayed
faster.
Nested functions: The functions, which are defined inside other functions,
are called Nested functions. They are called 'everytime' the main function is
invoked.
Screen objects are used to read the information from the client's screen. The
properties of screen objects are -