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: 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
2. 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
3. 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:
Correct Answer: The cursor can set to wait in JavaScript by using the property ?cursor? property The following example illustrates the usage windowdocumentbodystylecursor = "wait";
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: 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"
7. 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
Correct Answer: This is a scripting language developed by Microsoft and is based loosely on Visual Basic Its functionality in a web environment is dependant upon either an ASP engine or the Windows Scripting Host, and must be used on a Windows hosting platform
10. .What are the different types of environments available in the web?