Java Script Interview Questions and Answers

How do we get JavaScript onto a web page?

The script element can directly be added inside the body of the page. It should start with the tag <script> and end with </script> tag. The script can also be added to the head tag of the web page. Similarly the other way is by placing the script in a separate file which gets downloaded on the client's machine when the page is requested.
Embedded
<SCRIPT LANGUAGE='JavaScript Version'> JavaScript statements </SCRIPT>
Stored externally
<SCRIPT src='abc.js' />

How we can access Elements using java script?

Each elements of JavaScript can be accessed by their names. To access the page, document element is used and to access the browser the window element is used in the script. This element's values are required for several computing reason say validation check. 
For example:
var myID = windows.document.formLogin.userID.value;

What does isNaN function do?
Return true if the argument is not a number.
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 scriptable 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.
The second biggest can of worms is scripting connections between multiple windows. A lot of scripter's like to have little windows pop up with navigation bars or some such gizmos. But the object models, especially in the older browser versions, don't make it easy to work with these windows the minute you put a user in front of them--users who can manually close windows or change their stacking order.

How do you submit a form using JavaScript?

Use document.forms[0].submit();
0 refers to the index of the form's. 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 to create arrays in JavaScript?

We can declare an array like this 
var scripts = new Array(); 
We can add elements to this array like this

scripts[0] = 'PHP';
scripts[1] = 'ASP';
scripts[2] = 'JavaScript';
scripts[3] = 'HTML';
We also can create an array like this 
var no_array = new Array(21, 22, 23, 24, 25);

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. 
Alert ('Warning: Please enter an integer between 0 and 100.');
Confirm ('Do you really want to launch the missile?'); 

What is a prompt box/ input box?

A prompt box allows the user to enter input by providing a text box. 
Prompt ('What is your temperature?');

How about 2+5+'8'?

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

How to convert a string to a number using JavaScript?

You can use the parseInt() and parseFloat() methods. Notice that extra letters following a valid number are ignored. 
parseInt('100') ==> 100

How to convert numbers to strings using JavaScript?

You can append the number with an empty string 
var mystring = ' '+myinteger; 
or 
var mystring = myinteger.toString();

What does break and continue statements do?
Continue statement continues the current loop (if label not specified) in a new iteration whereas break statement exits the current loop.
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;

Latest Updates

Apache Tomcat

What is the difference between Apache Tomcat server and Apache web server?

MS-DOS

What is the full form of DOS?

Explain the use of help DOS Command?

How we can create a directory in DOS?

Analogy

Riddle:Solve

Limp:Walk

Molecule:Atoms

Misfortune:Catastrophe

Pipes and Cistern

A tank can be filled by one tap in 10 minutes and by another in 30 minutes. Both the taps are kept open for 5 minutes and then the first one is shut off. In how many minutes more is the tank completely filled?

Simplification

Assume that a sum of money is divided equally among n girls. Each girl will receive $60. If another girl is added to the group and the sum is divided equally among all the girls, each child girl gets a $50 share. What is the sum of money?

Problems on Trains

A 300 meter long metro train crosses a platform in a metro station in 39 seconds while it crosses a lamp post in 18 seconds. What is the length of the platform?

Problems on Ages

In a group of 7 people, the average age is found to be 17 years. Two more people joined with an average age 19 years. One person left the group whose age was 25 years. What is the new average age of the group?

Profit and Loss

Irvin sold a book at a profit of 12%. If Irvin had sold it for Rs 18 more, then 18% would have been gained. Find the cost price?

Chemistry

Non stick cooking utensils are coated with?

The group of metals Co, Ni, Fe may best called as?

General Knowledge of India

'Kanchipuram' is in which of the following states?

General Knowledge of World

In which year was Pulitzer Prize established?

Indian History

The roads of cities in the Indus Valley Civilization generally divided the city into?

Latest Job Notifications

Jobs in West Bengal

इंडियन पोस्ट सर्विस Indian Post Service - 2357 पद - 19/08/2021 अंतिम तिथि - पश्चिम बंगाल पोस्टल सर्कल

Banking Jobs

भारतीय स्टेट बैंक State Bank of India(SBI) - 6100 पद - 26/07/2021 अंतिम तिथि - CRPD/APPR/2021-22/10

SSC Recruitment

कर्मचारी चयन आयोग Staff Selection Commission(SSC) - 25271 पद - 31/08/2021 अंतिम तिथि

Jobs in Madhya Pradesh

राष्ट्रीय स्वास्थ्य मिशन मध्य प्रदेश National Health Mission MP(NRHM) - 5215 पद - 22/06/2021 अंतिम तिथि

Jobs in Punjab

पंजाब स्टेट पावर कॉर्पोरेशन लिमिटेड Punjab State Power Corporation Limited (PSPCL) - 2632 पद - 20/06/2021 अंतिम तिथि

Jobs in Chhattisgarh

स्वास्थ्य सेवा निदेशालय, छत्तीसगढ़ Department of Health & Family Welfare, Chhattisgarh - 267 पद - 26/06/2021 अंतिम तिथि

Government Jobs

दिल्ली सबऑर्डिनेट सर्विस सिलेक्शन बोर्ड Delhi Subordinate Services Selection Board(DSSSB) - 5807 पद - 03/07/2021 अंतिम तिथि

Jobs in Madhya Pradesh

राष्ट्रीय स्वास्थ्य मिशन मध्य प्रदेश National Health Mission MP(NRHM) - 2850 पद - 31/05/2021 अंतिम तिथि

Government Jobs

इंडियन पोस्ट सर्विस Indian Post Service - 4368 पद - 29/05/2021 अंतिम तिथि

दिल्ली सबऑर्डिनेट सर्विस सिलेक्शन बोर्ड Delhi Subordinate Services Selection Board(DSSSB) - 7236 पद - 24/06/2021 अंतिम तिथि