Correct Answer: The storage of cookies on the hard disk depends on OS and the browser The Netscape navigator on Windows, the file cookiestxt contains all the cookies The path is : c:\Program Files\Netscape\Users\username\cookiestxt The Internet Explorer stores the cookies on a file by name username@websitetxt is c:\Windows\Cookies\username@Websitetxt
Correct Answer: The elements of JavaScript are accessed by their names By default the browser is accessed by the element ?windows? and the page by ?document? The corresponding element has user defined names for forms and its elements For example var pwd = windowsdocumentfrmLoginpasswordvalue; assigns the value of the password field of the form fromLogin in the current document, where password is the name of the element and frmLogin is the name of the form Like wise any form element is accessed
Correct Answer: The cursor can set to wait in JavaScript by using the property ?cursor? property The following example illustrates the usage windowdocumentbodystylecursor = "wait";
4. What is decodeURI(), encodeURI() in JavaScript?
Correct Answer: To send the characters that can not be specified in a URL should be converted into their equivalent hex encoding To perform this task the methods encodeURI() and decodeURI() are used For example, the following code snippet performs the encoding of URL:
5. What are windows object and navigator object in JavaScript?
Correct Answer: Windows object is top level object in Java script It contains several other objects such as, document, history, location, name, menu bar etc, in itself Window object is the global object for Java script that is written at client-side Information pertaining to the client browser and system is returned by the navigator object of JavaScript Navigator object is the top level object for all users
Correct Answer: NaN stands for ?not-a-number? The function isNaN determines the argument or the value is a NaN The function returns true if the argument is not a number, otherwise returns false
Correct Answer: Files can be read and written by using java script functions ? fopen(),fread() and fwrite() The function fopen() takes two parameters ? 1 Path and 2 Mode (0 for reading and 3 for writing) The fopen() function returns -1, if the file is successfully opened Ex: file=fopen(getScriptPath(),0); The function fread() is used for reading the file content Ex: str = fread(file,flength(file)); The function fwrite() is used to write the contents to the file Ex(): file = fopen("c:\MyFiletxt", 3);// opens the file for writing fwrite(file, str);// str is the content that is to be written into the file
Correct Answer: Arrays are created by using new Array() in Java Script For example : var employees = new Array(); The elements to this array is assigned as follows : employees[0] = "Kumar" employees[1] = "Fedrick"
9. What are Math Constants and Functions using JavaScript?
Correct Answer: Math object has two constant : MathPI and MathE Math object has following functions: - Mathabs(val1); It will give absolute value of val1 - Mathmax(val1,val2); This fuction will return maximum value from val1 and val2 - Mathrandom(); This function will return a random number between 0 and 1 - Mathfloor(val1) This function will returns decimal value of val1
Correct Answer: -The shift() method is similar as the pop() method but the difference is that Shift method works at the beginning of the array -The shift() method take the first element off of the given array and returns it The array on which is called is then altered For example var myarray = ["apple ", "banana ", "mango "]; consolelog(myarrayshift()); consolelog(myarray); we get the following console output: apple ["banana ", "mango "]; When we call shift() on an empty array, it will return an undefined value