• +91 9723535972
  • info@interviewmaterial.com

Java Script Interview Questions and Answers

Java Script Interview Questions and Answers

Question - 11 : - What are JavaScript types?

Answer - 11 : - Number, String, Boolean, Function, Object, Null, Undefined.

Question - 12 : - How to create arrays in JavaScript?

Answer - 12 : - 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 - 13 : - Include the name of the frame in the target attribute of the hyperlink. >My Page

Question - 14 : - How do you convert numbers between different bases in JavaScript?

Answer - 14 : - 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 - 15 : - What is a fixed-width table and its advantages?

Answer - 15 : - 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 - 16 : - Where are cookies actually stored on the hard disk?

Answer - 16 : - 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  

Question - 17 : - What can javascript programs do?

Answer - 17 : - Generation of HTML pages on-the-fly without accessing the Web server. The user can be given control over the browser like User input validation Simple computations can be performed on the client's machine The user's browser, OS, screen size, etc. can be detected Date and Time Handling

Question - 18 : - How to add Buttons in JavaScript?

Answer - 18 : - The most basic and ancient use of buttons are the "submit" and "clear", which appear slightly before the Pleistocene period. Notice when the "GO!" button is pressed it submits itself to itself and appends the name in the URL. Your Name:

Another useful approach is to set the "type" to "button" and use the "onclick" event.
Select a Hero

Question - 19 : - How to set a HTML document's background color?

Answer - 19 : - document.bgcolor property can be set to any appropriate color.

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

Answer - 20 : - JavaScript allows a Web page to perform "if-then" 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. For example, an experienced CGI programmer can examine information about the browser whenever a request for a page is made; thus a server so equipped might serve up one page for Navigator users and a different page for Internet Explorer users. Beyond browser and operating system version, a CGI program can't know more about the environment. But a JavaScript-enhanced page can instruct the browser to render only certain content based on the browser, operating system, and even the screen size. 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. A script can save this information on the client in a well-regulated local file called a cookie. The next time the user comes to the site, scripts in its pages look to the cookie info and render the page in the color combination selected previously. The server is none the wiser, nor does it have to store any visitor-specific information.


NCERT Solutions

 

Share your email for latest updates

Name:
Email:

Our partners