Tuesday 5 April 2016

JavaScript Interview Questions





1)  What is JavaScript?
JavaScript is a lightweight programming language, designed to add interactivity to HTML pages. . It can enhance the dynamics and interactive features of your page by allowing you to perform calculations, check forms, write interactive games, add special effects, customize graphics selections, and create security passwords and more.

2) Are Java and JavaScript the Same?
NO, Java and JavaScript have almost nothing in common except for the name. Java is technically an interpreted programming language, it is coded in a similar fashion to C++, with separate header and class files, compiled together prior to execution. It is powerful enough to write major applications and insert them in a web page as a special object called an "applet”.  Whereas JavaScript is a lightweight programming language, designed to add interactivity to HTML pages

3) What are the features of JavaScript ?
  • JavaScript is powerful scripting languages that help HTML designers to effectively and interactively design websites and web pages in a very simple and efficient way.
  • It has features to achieve dynamic effects in web pages. 
  • One of the powerful features of JavaScript is its ability to detect client browser. It can detect the type of browser the visitor is using and programmatically switch the page to show customized pages designed for different browsers. 
  • A JavaScript can be used to store and retrieve information on the visitor's computer
  • It has the feature of validating data submitted at the client level. This helps in saving the processing time of the server, because JavaScript initially creates the validation on the client side.
  • JavaScript has simple rules and procedures that make it easier to use and learn for programmers. 
  • It is an interpreted language, meaning that it can be used or executed with ease without pre-compilation.
4) What are the advantages of JavaScript?
  • Simplicity. JavaScript is relatively simple to learn and implement.
  • Versatility. JavaScript plays nicely with other languages and can be used in a huge variety of applications. Unlike PHP or SSI scripts, JavaScript can be inserted into any web page regardless of the file extension. JavaScript can also be used inside scripts written in other languages such as Perl and PHP.
  • Server Load. Being client-side reduces the demand on the website server.
  • Less Server Interaction:  Being client-side, JavaScript is very fast because any code functions can be run immediately instead of having to contact the server and wait for an answer.
5) What are the disadvantages of JavaScript?
  • Security. Because the code executes on the users' computer, in some cases it can be exploited for malicious purposes. This is one reason some people choose to disable JavaScript.
  • Reliance on End User. JavaScript is sometimes interpreted differently by different browsers. Whereas server-side scripts will always produce the same output, client-side scripts can be a little unpredictable. Don't be overly concerned by this though - as long as you test your script in all the major browsers you should be safe.
  • JavaScript doesn't have any multithreading or multiprocessing capabilities.
6) What is Browser Object Model (BOM)?
Browser Object Model (BOM) provides interaction with the browser. The default object of browser is window.

7) What is Document Object Model (DOM)?
Document objects represent the html document. It can be used to access and change the content of html.

8) What is the use of window object?
The window object is automatically created by the browser that represents a window of a browser. It is used to display the popup dialog box such as alert dialog box, confirm dialog box, input dialog box etc.

9) What are the JavaScript data types?
  There are two types of data types in JavaScript:
  • Primitive Data Types
  • Non-primitive Data Types

10) What the difference is between == and ===?
      The == operator checks equality only whereas === checks equality and data type i.e. value must be of same type.

11) What does the isNaN () function?
      The isNan() function returns true if the variable value is not a number.

12) Difference between Client side JavaScript and Server side JavaScript?
·        Client side JavaScript comprises the basic language and predefined objects which are relevant to running java script in a browser. The client side JavaScript is embedded directly by in the HTML pages. This script is interpreted by the browser at run time.
·        Server side JavaScript also resembles like client side java script. It has relevant java script which is to run in a server. The server side JavaScript is deployed only after compilation.
13) What is negative infinity?
Negative Infinity is a number in JavaScript which can be derived by     dividing negative number by zero.

14) What is difference between View state and Session state?
View state is specific to a page in a session whereas Session state is specific to a user or browser that can be accessed across all pages in the web application.

15) What are the pop up boxes available in JavaScript?
  • Alert Box
  • Confirm Box
  • Prompt Box


0 comments:

Post a Comment