Thursday, November 1, 2012

Javascript Interview Questions set-02


  • What is JavaScript? JavaScript is a platform-independent,event-driven, interpreted client-side scripting and programming language developed by Netscape Communications Corp. and Sun Microsystems.
  • How is JavaScript different from Java? JavaScript was developed by Brendan Eich of Netscape; Java was developed at Sun Microsystems. While the two languages share some common syntax, they were developed independently of each other and for different audiences. Java is a full-fledged programming language tailored for network computing; it includes hundreds of its own objects, including objects for creating user interfaces that appear in Java applets (in Web browsers) or standalone Java applications. In contrast, JavaScript relies on whatever environment it's operating in for the user interface, such as a Web document's form elements.
    JavaScript was initially called LiveScript at Netscape while it was under development. A licensing deal between Netscape and Sun at the last minute let Netscape plug the "Java" name into the name of its scripting language. Programmers use entirely different tools for Java and JavaScript. It is also not uncommon for a programmer of one language to be ignorant of the other. The two languages don't rely on each other and are intended for different purposes. In some ways, the "Java" name on JavaScript has confused the world's understanding of the differences between the two. On the other hand, JavaScript is much easier to learn than Java and can offer a gentle introduction for newcomers who want to graduate to Java and the kinds of applications you can develop with it.
  • How do you submit a form using Javascript? Use document.forms[0].submit();
    (0 refers to the index of the form – if you have more than one form in a page, then the first one has the index 0, second has index 1 and so on).
  • How do we get JavaScript onto a web page? You can use several different methods of placing javascript in you pages.
    1. You can directly add a script element inside the body of page.
    2. Javascript can be placed inside the element
    3. Javascript can be referenced from a separate file
  • How to read and write a file using javascript? I/O operations like reading or writing a file is not possible with client-side javascript. However, this can be done by coding a Java applet that reads files for the script.
  • 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 are JavaScript Data types? JavaScript allows you to work with three primitive data types:
    1. Numbers eg. 123, 120.50 etc.
    2. Strings of text e.g. "This text string" etc.
    3. Boolean e.g. true or false.
    JavaScript also defines two trivial data types, null and undefined, each of which defines only a single value.
    In addition to these primitive data types, JavaScript supports a composite data type known as object.

    Note: Java does not make a distinction between integer values and floating-point values. All numbers in JavaScript are represented as floating-point values. JavaScript represents numbers using the 64-bit floating-point format defined by the IEEE 754 standard.
  • What can javascript programs do? Generation of HTML pages on-the-fly without accessing the Web server. The user can be given control over the browser like User input validation Simple computations can be performed on the client's machine The user's browser, OS, screen size, etc. can be detected Date and Time Handling.
  • How to set a HTML document's background color? document.body.bgColor="green";
  • What is negative infinity? It's a number in JavaScript, derived by dividing negative number by zero.
  • How to get the contents of an input box using Javascript? by using the "value" property.
    var myValue = window.document.getElementById("MyTextBox").value;
  • How to determine the state of a checkbox using Javascript? Use the "checked" property of the checkbox object. For example:
    var checkedP = window.document.getElementById("myCheckBox").checked;
  • How to set the focus in an element using Javascript? Use the "focus" property of the element. For example:
    document.getElementById("name").focus();
  • What is the difference between an alert box and a confirmation box? An alert box displays only one button which is the OK button whereas the Confirm box displays two buttons namely OK and cancel.
  • What is a prompt box? The prompt() is a method of the window object, just like alert(). The format for prompt() is similar to alert(), except for one addition. Prompt uses a text field to enter a value. It also has 'OK' and 'CANCEL' buttons, while the alert has only one button.
  • What does undefined value mean in javascript? Undefined value means the variable used in the code doesnt exist or is not assigned any value or the property doesnt exist.
  • What are undefined and undeclared variables? Undeclared variables are those that are not declared in the program (do not exist at all),trying to read their values gives runtime error.But if undeclared variables are assigned then implicit declaration is done.
    Undefined variables are those that are not assigned any value but are declared in the program.Trying to read such variables gives special value called undefined value. 


  • Please Share it! :)

    Ditulis Oleh : Nangraj Hari: 7:46 AM Kategori:

    0 comments:

    Post a Comment

     
    PLEASE VISIT MY OTHER BLOG TO DOWNLOAD LATEST FULL CRACKED SOFTWARES,GAMES,COMPUTER NOTES,VIDEO TUTORIALS,AND MUCH MORECLICK HERE