JavaScript Event

JavaScript Interview Questions and Answers

Javascript is an interpreted language with a C like syntax. While many people brush the language off as nothing more than a browser scripting language, it actually supports many advanced concepts such as object-oriented-programing, recursion, lambda, and closures. We can herewith list of latest and updated JavaScript Interview Questions and their answers for fresher’s as well as experienced users.  These JavaScript interview question covers latest version of JavaScript.   

Best JavaScript Interview Questions and Answers

External Javascript is where things get interesting. Any time you have a block of code which you will want to use on several different web pages you should place that block in an external Javascript file. Here you can find top best JavaScript Interview Questions and Answers for beginners and professionals,

What is JavaScript?

JavaScript is a general-purpose programming language designed to let programmers of all skill levels control the behaviour of software objects. The language is used most widely today in Web browsers whose software objects tend to represent a variety of HTML elements in document and the document itself. But the language can be–and is–used with other kinds of objects in other environments.

What’s relationship between JavaScript and ECMAScript?

ECMAScript is yet another name for JavaScript (other names include LiveScript). The current JavaScript that you see supported in browsers is ECMAScript revision 3.

How do you submit a form using JavaScript?

Use document. forms [0]. submit()

(0 refers to the index of the form — if we have more than one form in a page, then the first one has the index 0, second has index 1 and so on).

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. app Version string (property) should be used. 

What are JavaScript Data Types?

JavaScript Data Types are Number, String, Boolean, Function, Object, Null, Undefined

How can JavaScript be used to personalize or tailor a Web site to fit individual users?

JavaScript allows a Web page to perform &quotif-then&quot, kinds of decisions based on browser version, operating system, user input, and, in more recent browsers, details about the screen size in which the browser is running. While a server CGI program can make some of those same kinds of decisions, not everyone has access to or the expertise to create CGI programs.

Scripting can even go further if the page author desires. For example, the author may include a preference screen that lets the user determine the desired background and text color combination.

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.

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.

How can JavaScript make a Web site easier to use? That is, are there certain JavaScript techniques that make it easier for people to use a Web site?

JavaScript’s greatest potential gift to a Web site is that scripts can make the page more immediately interactive, that is, interactive without having to submit every little thing to the server for a server program to re-render the page and send it back to the client. For example, consider a top-level navigation panel that has, say, six primary image map links into subsections of the Web site.  

How can JavaScript be used to improve the "look and feel" of a Web site? By the same token, how can JavaScript be used to improve the user interface?

On their own, Web pages tend to be lifeless and flat unless you add animated images or more bandwidth-intensive content such as Java applets or other content requiring plug-ins to operate (Shockwave and Flash, for example).

Embedding JavaScript into an HTML page can bring the page to life in any number of ways. Perhaps the most visible features built into pages recently with the help of JavaScript are the so-called image rollovers: roll the cursor atop a graphic image and its appearance changes to a highlighted version as a feedback mechanism to let you know precisely what you’re about to click on. But there are less visible yet more powerful enhancements to pages that JavaScript offers.

How Interactive forms validation is an extremely useful?

Interactive forms validation is an extremely useful application of JavaScript. While a user is entering data into form fields, scripts can examine the validity of the data–did the user type any letters into a phone number field?, for instance. Without scripting, the user has to submit the form and let a server program (CGI) check the field entry and then report back to the user. This is usually done in a batch mode (the entire form at once), and the extra transactions take a lot of time and server processing power. Interactive validation scripts can check each form field immediately after the user has entered the data, while the information is fresh in the mind.

Are you concerned that older browsers don’t support JavaScript and thus exclude a set of Web users? individual users?

Fragmentation of the installed base of browsers will only get worse. By definition, it can never improve unless absolutely everyone on the planet threw away their old browsers and upgraded to the latest gee-whiz versions. But even then, there are plenty of discrepancies between the script ability of the latest Netscape Navigator and Microsoft Internet Explorer.

What does isNaN function do?

Return true if the argument is not a number. 

What is negative infinity?

It’s a number in JavaScript, derived by dividing negative number by zero.

In a pop-up browser window, how do you refer to the main browser window that opened it?

Use window. opener to refer to the main window from pop-ups. 

What is the data type of variables of in JavaScript?

All variables are of object type in JavaScript. 

Methods GET and POST in HTML forms – what’s the difference?

GET: Parameters are passed in the query string. Maximum amount of data that can be sent via the GET method is limited to about 2kb.

POST: Parameters are passed in the request body. There is no limit to the amount of data that can be transferred using POST. However, there are limits on the maximum amount of data that can be transferred in one name/value pair. 

How to write a script for “Select” lists using JavaScript?

  1. To remove an item from a list set it to null

mySelectObject.options[3] = null

  1. To truncate a list set its length to the maximum size you desire length = 2
  2. To delete all options in a select object set the length to 0. leng

Text From Your Clipboard?

It is true, text you last copied for pasting (copy & paste) can be stolen when you visit web sites using a combination of JavaScript and ASP (or PHP, or CGI) to write your possible sensitive data to a database on another server. 

What does the “Access is Denied” IE error mean?

The “Access Denied” error in any browser is due to the following reason.

A JavaScript in one window or frame is tries to access another window or frame whose document’s domain is different from the document containing the script. 

Are Java and JavaScript the Same?

No. java and JavaScript are two different languages.

Java is a powerful object – oriented programming language like C++, C whereas JavaScript is a client-side scripting language with some limitations. 

How to embed JavaScript in a web page?

JavaScript code can be embedded in a web page between <script langugage=”javascripe>

//Place Your JavaScript here.

</script>

tags

What and where are the best JavaScript resources on the Web?

The Web has several FAQ areas on JavaScript. The best place to start is something called the meta-FAQ [14-Jan-2001 Editor’s Note: I can’t point to it anymore, it is broken!], which provides a high-level overview of the JavaScript help available on the Net. As for fact-filled FAQs, I recommend one maintained by Martin Webb and a mini-FAQ that I maintain.

What are the problems associated with using JavaScript, and are there JavaScript techniques that you discourage?

Browser version incompatibility is the biggest problem. It requires knowing how each script able browser version implements its object model. You see, the incompatibility rarely has to do with the core JavaScript language (although there have been improvements to the language over time); the bulk of incompatibility issues have to do with the object models that each browser version implements. 

How to get the contents of an input box using JavaScript?

Use the “value” property.

var myValue = window.document.getElementById(“MyTextBox”).value; 

How to determine the state of a checkbox using JavaScript?

Determining the state of a checkbox in JavaScript

var checkedP = window.document.getElementById(“myCheckBox”).checked; 

How to set the focus in an element using Javascript?

Setting the focus in an element using JavaScript

<script>
function setFocus() 1 if(focusElement != null)
{ document.forms[0].elementsrmyelementnamel.focus();
1 I </script>

Can JavaScript code be broken in different lines?

Breaking is possible within a string statement by using a backslash at the end but not within any other javascript statement. that is,

document.write(“Hello world”);

is possible but not document.write

(“hello world”); 

Taking a developer’s perspective, do you think that that JavaScript is easy to learn and use?

One of the reasons JavaScript has the word “script” in it is that as a programming language, the vocabulary of the core language is compact compared to full-fledged programming languages. If you already program in Java or C, you actually have to unlearn some concepts that had been beaten into you. F

What Web sites do you feel use JavaScript most effectively (i.e., best-in-class examples)? The worst?


The best sites are the ones that use JavaScript so transparently, that I’m not aware that ther is any scripting on the page. The worst sites are those that try to impress me with how much scripting is on the page. 

How about 2+5+”8″?

Since 2 and 5 are integers, this is number arithmetic, since 8 is a string, it’s concatenation, so 78 is the result. 

What is the difference between SessionState and ViewState?

ViewState is specific to a page in a session. Session state refers to user specific data that can be accessed across all pages in the web application. 

What looping structures are there in JavaScript?

JavaScript supports the for loop, while loop, do-while loop, but there is no for each loop in JavaScript. 

To put a “close window” link on a page?

<a hreMavascript:window.close0' class='anyCSSClass'> Close </a>

How to hide JavaScript code from old browsers that don’t run it?

Use the below specified style of comments <script language=javascript> <!– javascript code goes here // –> or Use the <NOSCRIPT>some html code </NOSCRIPT> tags and code the display html statements between these and this will appear on the page if the browser does not support JavaScript

What is this keyword?

In JavaScript this key work refers to the current object.

Does the term sticky session mean in a web-farm scenario? Why would you use a sticky session? What is the potential disadvantage of using a sticky session?

Sticky session refers to the feature of many commercial load balancing solutions for web-farms to route the requests for a particular session to the same physical machine that serviced the first request for that session. This is mainly used to ensure that in-proc session is not lost as a result of requests for a session being routed to different servers.

We have tried to cover most of the questions, which are generally asked in an interview related to the JavaScript.  You can go through these answers in order to understand the functions and various other technical terms.

So if you have finally found your dream job in JavaScript coder/or developer but are wondering how to crack the JavaScript Interview and what could be the probable JavaScript Interview Questions. Every interview is different and the scope of a job is different too. Hope above assist you to get a dream Job. Keep Learn.

Online Training Tutorials

  • XML Interview QuestionsXML Interview Questions and AnswersBelow is the list of latest and updated XML interview questions and their answers for fresher’s as well as experienced users. These interview question covers basic and latest version of […]
  • VBScript Interview Questions and AnswersVBScript Interview Questions and AnswersVBScript is a powerful but easy-to learn scripting language that you can use to perform a number of useful activities, including enhancing your web pages and automating repetitive or […]
  • Siebel Interview Questions and AnswersSiebel Interview Questions and AnswersSiebel is a CRM (Customer Relationship Management) application. It is mainly deployed by companies which have huge customer base and expect regular interaction with them. There are other […]
  • Ruby Interview QuestionsRuby Interview Questions and AnswersProgramming Ruby is known to Rubyists. It is a tutorial and reference for the Ruby programming language. Before we start talking about the Ruby language, it’d be useful if we helped you […]
  • PHP Interview QuestionsPHP Interview Questions and AnswersBelow is the list of latest and updated PHP interview questions and their answers for fresher’s as well as experienced users.  The combination of PHP and MySQL is the most convenient […]
  • JavaScript EventJavaScript EventJavaScript Event : Imagine an interface where the only way to find out whether a key on the keyboard is being pressed is to read the current state of that key. To be able to react to […]
  • JavaScript Node.jsJavaScript Node.jsJavaScript Node.js, a program that allows you to apply your JavaScript skills outside of the browser. With it, you can build anything from small command line tools to HTTP servers that […]
  • JavaScript ScopeJavaScript ScopeJavaScript Scope refers to the variables that are available to a piece of code at a given time. A lack of understanding of scope can lead to frustrating debugging experiences. When a […]