Presentation is loading. Please wait.

Presentation is loading. Please wait.

Comments Introduction to JavaScript © Copyright 2016, Fred McClurg All Rights Reserved.

Similar presentations


Presentation on theme: "Comments Introduction to JavaScript © Copyright 2016, Fred McClurg All Rights Reserved."— Presentation transcript:

1 Comments Introduction to JavaScript © Copyright 2016, Fred McClurg All Rights Reserved

2 JavaScript Comments What is a comment? Information that is ignored by JavaScript What purpose do comments serve? 1.Provides code documentation for self 2.Provides code documentation for others 3.Improves readability and maintainability 4.Promotes reuse 5.Disabling code (for debugging) 2

3 Inline Comment Single Line Comment: The “ // ” is for commenting a single line. From “ // ” to end of line is ignored. Example: // Single line comment. // Code following slash-slash // to end of line is ignored // Often used after statement var x = 4; // inline comment 3 slashSlash.html

4 Multi-line Comment: Multiple Line (or Block) Comment: /* single line comment */ /* * multiple line * block comment */ 4 slashStar.html

5 Comment Disabling Code Disabling Code: // Disabling parts of code var calendar = { // 'year': 2016, /* 'month': 'Dec', 'day': 25, */ 'holiday': 'Christmas', }; console.log( calendar ); 5 disableCode.html


Download ppt "Comments Introduction to JavaScript © Copyright 2016, Fred McClurg All Rights Reserved."

Similar presentations


Ads by Google