Tuesday 23 October 2012

Javascript Interview Questions

1) Explain in brief about Java script?
Java Script, originally supported by netscape navigator, is the most popular web scripting language. Java Script lets you embed programs right in your web pages and run these programs using the web browser. With the introduction of dynamic html necessity of Java Script is becoming more of a necessity.

2) Explain about the structured programming features of Java Script?
Java script supports most of the structured programming syntax present in programming language. It doesn't support scoping which is present in C programming in block style. It also supports various forms and methods of testing the type of an object which also includes the famous duck type testing.

3) Explain about inner functions and closures present in Function level programming?

Each time the outer function is invoked an inner function is created. Variables for the outer function still continue to exist as long as the inner function exists. This process continues until invocation exists. This is the how closures work within the JavaScript with all its functionalities.

4) Explain functions as object constructors?
If you prefix a new with a function call creates a new object and you can call that functions with a local keyword which is attached to that object. Object prototype property determines the functions prototype property. These functions act as object constructors along with their normal properties.

5) Explain functions as methods?

There is no big distinction between function definition and method definition. The only difference occurs when you actually call that function as a method which inturn is attached to an object. When the function is called in this manner its local keyword is bound to that object.

6) Explain about run time environment of Javascript?
Java script does not have a sophisticated run time of its own but it relies on the web browser of the client. It relies on this run time environment for its functions and methods to perform their duties by which scripts can interact with the user.

7) Explain about Variadic functions?
When you use variadic function in Javascript, an indefinite number of parameters can be passed onto the function. Inturn the function can access the parameters through formal parameters and local arguments. Variadic functions are much successful when you need to assign different number of parameters to functions.

8) State some simple usages with Javascript?

Some of the simple usages with Javascript are
1) A new pop up window can be made and changed according to the requirements such as no menus, scroll bars, etc.
2) Validation of input values submitted by the user through a web form.
3) Mouse over effects, scroll effects etc which can be changed by the scroll of the mouse pointer over a certain image, etc.

9) What is a JavaScript engine?
Java Script engine was first created by Netscape navigator. This engine interrupts the java script code and executes accordingly. The most common Java Script user interface is the web browser. Java script engine was created by Brendan.

10) Explain about the security functions presents in JavaScript?
As JavaScript uses Web as an interface it gives an ample scope for users to transfer malicious scripts. Most of the JavaScript related breaches and wrong doings are due to sandbox or same origin policy.

11) What are the precautions taken by the web browsers to contain malicious activity with Java Script?
Java script activities are restricted by web browsers in two ways they are.
1) First scripts run in sandbox which performs the most basic functions such as executing or running the code or script. This doesn't allow programming activities.
2) Scripts present in one site cannot have access to other sites; this is done with the help of same origin policy.

12) What are the rare cases when Java Script will not function?
These are the following cases when Java Script will not function.
1) An old browser which doesn't support DOM.
2) PDA or Mobile Phone will not execute Java Script.
3) Security reasons will not allow optimal performance of Jscript.
4) Speech browsers will not allow the functioning of Jscript.

13) Explain about Cross site scripting?

Cross site scripting raises security threats during execution and secured data transfer through web sites. It uses same origin policy. When a malicious script is made to run it discloses private information to the wrong person. This occurs because some one clicks on the request sent by the wrong doer.

14) Explain about arrays in Java Script?
Array maps everything from an integer to Values. Objects map everything from values to integers, Javascript specialize in certain special functions through which they can include integer indicies in their behavior. Large indicies can be removed if the length of the array specified is very small.

15) Explain about defining numbers in Java Script?

Java Script represents numbers in the form of IEEE-754 doubles. This form of representation provides accuracy upto 14-15 significant digits. They represent fractions but not the decimal numbers to an extent. To perform explicit numeric conversion you can use Number constructor.

16) Explain about strings in JavaScript?
Strings are represented as a sequence of characters in Javascript. Strings can be created when you place characters between double quotations or single quotations. Individual characters can be accessed by arrays.

17) Explain about the Boolean functions present in Javascript?

Three Boolean operators are present in Javascript they are
1) &&
2) II
3) /
All the operators are regarded as true unless the Javascript regards them as false. You can define these operators to make as statement false number 0 , null, undefined, or a string of length 0, etc. Boolean function performs these conversions explicitly. 

No comments:

Post a Comment