Summary - CGS3066: Web Programming and Design Summer 2014
JavaScript is a lightweight, interpreted programming language Designed for creating network-centric applications Complementary to and integrated with Java Complementary to and integrated with HTML Open and cross-platform JavaScript Syntax: A JavaScript consists of JavaScript statements that are placed within the script... /script HTML tags in a web page. You can place the script tag containing your JavaScript anywhere within you web page but it is preferred way to keep it within the head tags. The script tag alert the browser program to begin interpreting all the text between these tags as a script. So simple syntax of your JavaScript will be as follows script ... JavaScript code /script The script tag takes two important attributes: language: This attribute specifies what scripting language you are using. Typically, its value will be javascript. Although recent versions of HTML (and XHTML, its successor) have phased out the use of this attribute. type: This attribute is what is now recommended to indicate the scripting language in use and its value should be set to "text/javascript". So your JavaScript segment will look like: script language="javascript" type="text/javascript" JavaScript code /script Your First JavaScript Script: Let us write our class example to print out "Hello World". Tutorials Point, Simply Easy Learning 2 | P a g e html body script language="javascript" type="text/javascript" !-- ("Hello World!") //-- /script /body /html Above code will display following result: Hello World! Whitespace and Line Breaks: JavaScript ignores spaces, tabs, and newlines that appear in JavaScript programs. Because you can use spaces, tabs, and newlines freely in your program so you are free to format and indent your programs in a neat and consistent way that makes the code easy to read and understand. Semicolons are Optional: Simple statements in JavaScript are generally followed by a semicolon character, just as they are in C, C++, and Java. JavaScript, however, allows you to omit this semicolon if your statements are each placed on a separate line. For example, the following code could be written without semicolons script language="javascript" type="text/javascript" !-- var1 = 10 var2 = 20 //-- /script But when formatted in a single line as follows, the semicolons are
Written for
- Institution
- CGS3066: Web Programming and Design Summer 2014
- Course
- CGS3066: Web Programming and Design Summer 2014
Document information
- Uploaded on
- July 8, 2024
- Number of pages
- 39
- Written in
- 2023/2024
- Type
- SUMMARY
Subjects
-
tutorials point simply easy learning 1 p a g e