Set - 1

Question 11 :

How do you convert numbers between different bases in JavaScript?

Answer :

Use the parseInt() function, that takes a string as the first parameter, and the base as a second parameter. So to convert hexadecimal 3F to decimal, use parseInt ("3F", 16);


Question 12 :

How to create arrays in JavaScript? 

Answer :

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";

Now our array scrips has 4 elements inside it and we can print or access them by using their index number. Note that index number starts from 0. To get the third element of the array we have to use the index number 2 . Here is the way to get the third element of an array. 
document.write(scripts[2]); 
We also can create an array like this 
var no_array = new Array(21, 22, 23, 24, 25);


Question 13 :

How do you target a specific frame from a hyperlink? 

Answer :

Include the name of the frame in the target attribute of the hyperlink. <a href="mypage.htm" target="myframe">>My Page</a>


Question 14 :

What is a fixed-width table and its advantages?

Answer :

Fixed width tables are rendered by the browser based on the widths of the columns in the first row, resulting in a faster display in case of large tables. Use the CSS style table-layout:fixed to specify a fixed width table. 
If the table is not specified to be of fixed width, the browser has to wait till all data is downloaded and then infer the best width for each of the columns. This process can be very slow for large tables.

Example of using Regular Expressions for syntax checking in JavaScript 

var re = new RegExp("^(&[A-Za-z_0-9]{1,}=[A-Za-z_0-9]{1,})*$");
var text = myWidget.value;
var OK = re.test(text);
if( ! OK ) {
	alert("The extra parameters need some work.\r\n Should be something like: \"&a=1&c=4\"");
}

 


Question 15 :

Where are cookies actually stored on the hard disk?

Answer :

This depends on the user's browser and OS.
In the case of Netscape with Windows OS,all the cookies are stored in a single file called

cookies.txt 
c:\Program Files\Netscape\Users\username\cookies.txt 
In the case of IE,each cookie is stored in a separate file namely username@website.txt. 
c:\Windows\Cookies\username@Website.txt