Preview

JavaScript

Satisfactory Essays
Open Document
Open Document
504 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
JavaScript
1. Give the syntax of do..while statement. while (condition) { code block to be executed
}
2. Explain how an image could be accessed by name and by array number.
You can access an image by name by simply putting the name between quotes in a string within the []. To access an image by number you must firstgive each image a number in the image array. The images should be numbered in the order that they appear in the source code. var document.images=new Array (3) document.images[0]="ImageOne.png" document.images[1]="ImageTwo.png"

document.images["image01"]
3. Write a function that uses substring method of String object to get the 'Scr' part of the string 'JavaScript'. Also use the length property and write the length of the string 'JavaScript' and use the charAt method to get the 'S' from 'JavaScript' and write that. var str="JavaScript"; document.write(str.substring(4,7)+" ");

var str = "JavaScript"; document.write(str.charAt(str.length -6));

4. Explain how a Date object's instance is created and used. Also describe any three methods of the Date object.
Date objects are created with the new Date() constructor. They are used to work with dates and times such as months, years, or even milliseconds. You can use the Date object without parameters, which makes a new date object with the current date and time. You can also use the Date object with a date string, which makes a new date object with the specified date and time. Or you could use the Date object with a number, which makes a new date object with number of millisecond since 1970/01/01.
5. Write a function to output the names and values of a form's fields using the elements property of the form.

Name: Email:

var frm_element = document.getElement ById ('subscribe_frm');
6. Give syntax of calling JavaScript functions from button, checkbox and text objects. function isChecked(form) { var checked =

You May Also Find These Documents Helpful