3ProgramStructureII

# 3ProgramStructureII - Program Structure II Insertion of...

This preview shows pages 1–5. Sign up to view the full content.

(CS1301) Introduction to Computer Programming City Univ of HK / Dept of CS / Helena Wong 3. Program Structure II - 1 http://www.cs.cityu.edu.hk/~helena Program Structure II Program Structure II [Please switch off your phone] Insertion of Semicolons (;) Location of JavaScript Blocks Names of Variables and Functions Enclose statements in Braces { and } Assignment Statements Data Types (Numbers, Strings, Booleans) and Operations

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
(CS1301) Introduction to Computer Programming City Univ of HK / Dept of CS / Helena Wong 3. Program Structure II - 2 http://www.cs.cityu.edu.hk/~helena The mystery of Semicolons (;) • Semicolons ( ; ) are used to separate statements from each other. But manually adding semicolon is a common practice. (In Java, C . ., adding semicolon is a must. Most programmers have adapted this rule already) • Sometimes we get trouble if we handle line break or semicolon with mistake. Don’t rely on the automatic insertion of semicolons. (Refer to Q&A at course web) a = 3 b = 4 alert(a+b) a = 3 ; b = 4 ; alert(a+b) ; //c a lc ula te  a ve ra g e  o f m a rks : va r a  =  ( pa rs e Int(do c um e nt.F1.C Ma rk.va lue ) + pa rs e Int(do c um e nt.F1.EMa rk.va lue ) + pa rs e Int(do c um e nt.F1.MMa rk.value )) / 3 a le rt(a ) The fact: JavaScript automatically inserts semicolons if the line seems to be complete. a  = 3 b  = 4 a  = 3 b  = 4 a  = 3; b  = 4; //c a lc ula te  a ve ra g e  o f m a rks : / 3 ; a le rt(a ) ; Can be omitted if each statement is on a separate line. Example: a = 3; b = 4; The invisible semicolons are automatically inserted.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
(CS1301) Introduction to Computer Programming City Univ of HK / Dept of CS / Helena Wong 3. Program Structure II - 4 http://www.cs.cityu.edu.hk/~helena Names of Variables and Functions JavaScript is case-sensitive : keywords, variables, function names, etc. . must be consistent in capitalization of letters.
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 04/16/2011 for the course CS 1301 taught by Professor Dr.wong during the Winter '08 term at City University of Hong Kong.

### Page1 / 19

3ProgramStructureII - Program Structure II Insertion of...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online