Java Script

Interview Questions on Java Script

11. How to append the content to particular div element?

document.getElementById(‘#idname).innerHTML += ‘html code goes here’ ;

12. How to get value of input box in javascript?

document.getElementById(‘#idname).value;

13. How to declare and initialize variables?

Syntax :- var van_name = value;
Ex:-  var var1 = 5;

14. How to concat two strings in javascript?

By using +
Ex:- var var = “string1”+”string2”;

Ex 2:- 
var var1 = ”string1”;
var var2 = “string2”; 
var var3 = var1 + var2;

15. How to write comments in javascript?

Method1 :-  // comments goes here
Method2 :-  /* comments goes here */

16. What are the rule to write an identifier?

The general rules for constructing names for variables (unique identifiers) are:
1. Names can contain letters, digits, underscores, and dollar signs.
2. Names must begin with a letter
3. Names can also begin with $ and _ (but we will not use it in this tutorial)
4. Names are case sensitive (y and Y are different variables)
5. Reserved words (like JavaScript keywords) cannot be used as names

17. Are Javascript Identifiers case sensitive?

Yes

18. What are the ways to write multiple words as variablename?

1. Use _ b/w words.
2. Use camelcase(capital letter for every first letter).

19. Tell me some of the javascript keywords?

var,if, while,for, break,continue,function,new

20. How to convert string to number?

Integer.parseInt(“string value”);


www.000webhost.com