Presentation is loading. Please wait.

Presentation is loading. Please wait.

JavaScript Syntax Fort Collins, CO Copyright © XTR Systems, LLC Introduction to JavaScript Syntax Instructor: Joseph DiVerdi, Ph.D., MBA.

Similar presentations


Presentation on theme: "JavaScript Syntax Fort Collins, CO Copyright © XTR Systems, LLC Introduction to JavaScript Syntax Instructor: Joseph DiVerdi, Ph.D., MBA."— Presentation transcript:

1 JavaScript Syntax Fort Collins, CO Copyright © XTR Systems, LLC Introduction to JavaScript Syntax Instructor: Joseph DiVerdi, Ph.D., MBA

2 JavaScript Syntax Fort Collins, CO Copyright © XTR Systems, LLC Tricky Language Looks About as Complicated as BASIC Is Much More Complex Than BASIC –Use of Objects –Arguments to Functions Requires Careful Understanding of Argument Passing by–value by–reference Lots of Non-intuitive Aspects Lots of Very Tricky Details

3 JavaScript Syntax Fort Collins, CO Copyright © XTR Systems, LLC Object -Oriented Language Different style of programming –Traditional Programming called Function-Oriented Data & Functions –Useful Modern way of Thinking About Programs Some Definitions: object: a data structure with a collection of behaviors that can be performed on it method: a behavior performed on an object class: a definition of methods inherit: receive definitions instance: individual representative of a category

4 JavaScript Syntax Fort Collins, CO Copyright © XTR Systems, LLC Example Syntax Two Parts to Most JavaScript: –Function Definitions Tell the Browser What to Do Not required –References To Those Functions Required

5 JavaScript Syntax Fort Collins, CO Copyright © XTR Systems, LLC JavaScript Syntax This Will Be a Synopsis of Important Topics See Part I in Textbook –For Additional Details –aka Chapters 2-11

6 JavaScript Syntax Fort Collins, CO Copyright © XTR Systems, LLC JavaScript Syntax JavaScript is a cAsE-sEnSiTtiVe Language –Many Items are Defined in the Language Use the Case as Defined –You Will Define Many of Your Own Items Use the Case You Define HTML is a case-INSENSITIVE Language –Keep in Mind Where HTML Ends, JavaScript Starts, & vice versa Bad News –Some Browser Versions are Case-Insensitive Don't Yield to the Temptation...

7 JavaScript Syntax Fort Collins, CO Copyright © XTR Systems, LLC JavaScript Syntax JavaScript Identifiers are –Variable Names –Function Names –Label Names

8 JavaScript Syntax Fort Collins, CO Copyright © XTR Systems, LLC JavaScript Syntax Identifiers are Composed of Any Number of Legal Characters –Letters (a-z, A-Z) –Digits (0-9) –Underscore ( _ ) –Dollar sign ($) The First Character Must Not Be a Digit In Certain Early Versions –The $ Character is Not Allowed

9 JavaScript Syntax Fort Collins, CO Copyright © XTR Systems, LLC Programming Suggestions Use All Lower Case For Your Identifiers –It's Easier To Remember Write Out Words in Identifiers –It's Easier To Read (& Maintain) Use Underscore to separate Words –Very Readable for You –Very Readable for ESL Programmers

10 JavaScript Syntax Fort Collins, CO Copyright © XTR Systems, LLC Programming Suggestions For Example: name_first name_last address_email address_street address_city,... Or For Helpful Sorting: _01_name_first _02_name_last _03_address_email _04_address_street _05_address_city,...

11 JavaScript Syntax Fort Collins, CO Copyright © XTR Systems, LLC JavaScript Syntax Keywords –The Following Keywords are Part of the JavaScript Language & May Not be Used as Identifiers: break case continue default delete do else export false for function if import in new null return switch this true typeof var void while with –The Following Words are Reserved & May Not be Used as Identifiers: catch class const debugger enum extends finally super throw try –Keywords are Always Used in Lower Case

12 JavaScript Syntax Fort Collins, CO Copyright © XTR Systems, LLC JavaScript Syntax Tokens –Keyword –Variable Name –Function Name –Number –Regular Expression Pattern –Operators

13 JavaScript Syntax Fort Collins, CO Copyright © XTR Systems, LLC JavaScript Syntax Whitespace –JavaScript Ignores Whitespace Space Tab Return –Whitespace is Located Between Tokens –You Should Use Whitespace To Format Your Code –In a Readable Fashion

14 JavaScript Syntax Fort Collins, CO Copyright © XTR Systems, LLC JavaScript Syntax Semicolons –A JavaScript Statement Ends With a Semicolon –When a Statement is Ends with Newline The Terminating Semicolon May Be Omitted –Danger - Don't omit it! –Funny Rule About Line Breaks "You Cannot Read a Statement Across Two Lines if The First Line Can Be Interpreted as a Legal Statement on Its Own." –Subtle, non-intuitive, error prone –Always Terminate Statements With Semicolon –Use Your Editor's Line Wrapping For Readability

15 JavaScript Syntax Fort Collins, CO Copyright © XTR Systems, LLC JavaScript Syntax Comments –JavaScript Supports Both C & C++ Comments –C Comment Text, On One or More Lines, Between /* and */ /* Here is a comment Here is some more of the same comment */ –C++ Comment Text Between // & The End of The Current Line // Here is a comment // Here is another comment // Yes, this is yet another comment


Download ppt "JavaScript Syntax Fort Collins, CO Copyright © XTR Systems, LLC Introduction to JavaScript Syntax Instructor: Joseph DiVerdi, Ph.D., MBA."

Similar presentations


Ads by Google