JavaScript is a case-sensitive language made up of statements that tell the browser what to do. Statements are commands executed in the order they are written and usually end with a semicolon. Code blocks group statements together, starting with an opening curly brace and ending with a closing curly brace. An example shows writing a heading and two paragraphs to a web page using three document.write statements within script tags.
Download as DOC, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
19 views
05 Statements
JavaScript is a case-sensitive language made up of statements that tell the browser what to do. Statements are commands executed in the order they are written and usually end with a semicolon. Code blocks group statements together, starting with an opening curly brace and ending with a closing curly brace. An example shows writing a heading and two paragraphs to a web page using three document.write statements within script tags.
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2
JavaScript Statements
JavaScript is a sequence of statements to be executed by the browser.
JavaScript is Case Sensitive Unlike HT!" JavaScript is case sensitive # therefore watch your capitali$ation closely when you write JavaScript statements" create or call variables" ob%ects and functions. JavaScript Statements & JavaScript statement is a command to a browser. The purpose of the command is to tell the browser what to do. This JavaScript statement tells the browser to write 'Hello (olly' to the web pa)e* document.write("Hello Dolly"); +t is normal to add a semicolon at the end of each executable statement. ost people think this is a )ood pro)rammin) practice" and most often you will see this in JavaScript examples on the web. The semicolon is optional ,accordin) to the JavaScript standard-" and the browser is supposed to interpret the end of the line as the end of the statement. .ecause of this you will often see examples without the semicolon at the end. Note: Usin) semicolons makes it possible to write multiple statements on one line. JavaScript Code JavaScript code ,or %ust JavaScript- is a sequence of JavaScript statements. /ach statement is executed by the browser in the sequence they are written. This example will write a headin) and two para)raphs to a web pa)e* /xample <script type="text/javascript"> document.write("<!>"is is a eadin#</!>"); document.write("<p>"is is a para#rap.</p>"); document.write("<p>"is is anoter para#rap.</p>"); </script> JavaScript .locks JavaScript statements can be )rouped to)ether in blocks. .locks start with a left curly bracket 0" and ends with a ri)ht curly bracket 1. The purpose of a block is to make the sequence of statements execute to)ether. This example will write a headin) and two para)raphs to a web pa)e* /xample <script type="text/javascript"> $ document.write("<!>"is is a eadin#</!>"); document.write("<p>"is is a para#rap.</p>"); document.write("<p>"is is anoter para#rap.</p>"); % </script> The example above is not very useful. +t %ust demonstrates the use of a block. 2ormally a block is used to )roup statements to)ether in a function or in a condition ,where a )roup of statements should be executed if a condition is met-. 3ou will learn more about functions and conditions in later chapters.
JavaScript Fundamentals: JavaScript Syntax, What JavaScript is Use for in Website Development, JavaScript Variable, Strings, Popup Boxes, JavaScript Objects, Function, and Event Handlers: JavaScript Syntax, What JavaScript is Use for in Website Development, JavaScript Variable, Strings, Popup Boxes, JavaScript Objects, Function, and Event Handlers
JavaScript Fundamentals: JavaScript Syntax, What JavaScript is Use for in Website Development, JavaScript Variable, Strings, Popup Boxes, JavaScript Objects, Function, and Event Handlers