Java Script Interview Questions
few important javascript inteview question
if you know the answer do post them
it would be very helpful
1.JavaScript and JScript?
How and in what ways does JavaScript differ from JScript?
JavaScript is the ECMAScript standard, whereas JScript is the microsoft specific flavour that is restricted to version 1.3 of ECMAScript.
2.Redirecting a page
How to redirect a page using JavaScript
location.href = 'page.html';
3.Implement Timer Control
How to implement timer control in JavaScript
myTimer = setTimeout(fn, time);
4.Java swing
why is java swing so efficiently used in most graphics programming and not effected by systems graphic properties?
Swing is to do with Java, not JavaScript. It's the difference between cat and catburgler
5.Differenece between @Posted commands and @commands
That's not JavaScript either.
6.How do you call function in javascript?
You place parenthesis on the end of the function name.
7.How do you get field value in javascript?
var text = field.value;
8.How do you check validations in javascript?
form.onsubmit = validate;
9.Difference between computed field and Computed for display?
That's not JavaScript either.
10.How do you restrict user not to copy web page in Java Script ?
You cannot because the web page is publicly accessible. Some people try to disable the right-click button, but there are always easy workarounds.
11.Script to check every character
Write a code to get the text box data and to check each and every char?
javascript Code:
var text = form[field].value;
return validates = !!(/^[a...z]+$/.exec(text));
12.How will you insert data into db2 using JavaScript?
By using AJAX
13.What is flapjax and what are its benefits compared to javascript . How it converts flapjax code to javascript
flapjax is a templating library built on top of JavaScript..
The flapjax compiler converts it into JavaScript
14.How to validate a Email-address, in Form using JavaScript?
With the following regular expression from
http://www.regular-expressions.info/email.html
javascript Code:
/(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])/
There are simpler less effective email validations that can be performed too. For example:
javascript Code:
/\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/
15.What is the difference between java and java script?
That's like asking what's the difference between C++ and C# - they're both completely different languages designed for different purposes.
16.How to prevent a window not to be clicked or selected any way in java script?
Don't load the window. Seriously.
17.What are the methods of validating whether the form is secure?
All client-side forms are insecure, because you can't guarantee that javascript will be running when the form is submitted. Best results are by validating the form on the server-side, then use JavaScript to improve the user experience.
18.Write sample code for pagination using java script.
Use jQuery
javascript Code:
function pageselectCallback(page_id, jq) {
$('#Searchresult').text("Showing search results " + ((page_id * 10) + 1) + "-" + ((page_id * 10) + 10));
}
$(document).ready(function() {
// Create pagination element
$("#Pagination").pagination(300, {
num_edge_entries: 2,
num_display_entries: 8,
callback: pageselectCallback
});
}
19.What is javascript and what is it functionality?
JavaScript is a client-side scripting language.
20.What is the main difference between Client side JavaScript and and Server side Java Script. How actually
Client-side runs on the client but you cannot guarantee that javascript is enabled on the client. Server-side will always run providing the client supports that feature.
21.Explain about session? Where it runs & what are different types of session handling?
Sessions run on the server and use cookies to store state information.
22.How to add a combo box dynamically at run time in Java script?
By using the DOM.
23.How to go next field without filling the text? Which function should use.Phone No Text validation in
Use the mouse to click on the next field. The function to use for phone no text validation is
24.How to use email validation in Java script.Like User can't enter invalid email address?
Validate the form on the server-side, then perform client-side validation to improve the user experience.