SlideShare a Scribd company logo
1. JavaScript Overview
What is JavaScript ?
 JavaScript started life as LiveScript, but Netscape changed the
name, possibly because of the excitement being generated by
Java.to JavaScript. JavaScript made its first appearance in
Netscape 2.0 in 1995 with a name LiveScript.
 JavaScript is a lightweight, interpreted programming language
with object-oriented capabilities that allows you to build
interactivity into otherwise static HTML pages.
 The general-purpose core of the language has been embedded
in Netscape, Internet Explorer, and other web browsers
JavaScript is:
 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
 Client-side JavaScript is the most common form of the
language. The script should be included in or referenced by an
HTML document for the code to be interpreted by the browser.
 It means that a web page need no longer be static HTML, but
can include programs that interact with the user, control the
browser, and dynamically create HTML content.
 The JavaScript code is executed when the user submits the
form, and only if all the entries are valid they would be
submitted to the Web Server.
 JavaScript can be used to trap user-initiated events such as
button clicks, link navigation, and other actions that the user
explicitly or implicitly initiates.
Client-side JavaScript:
Advantages of JavaScript:
The merits of using JavaScript are:
 Less server interaction: You can validate user input before
sending the page off to the server. This saves server traffic,
which means less load on your server.
 Immediate feedback to the visitors: They don't have to wait
for a page reload to see if they have forgotten to enter
something.
 Increased interactivity: You can create interfaces that react
when the user hovers over them with a mouse or activates
them via the keyboard.
 Richer interfaces: You can use JavaScript to include such items
as drag-and-drop components and sliders to give a Rich
Interface to your site visitors.
Limitations with JavaScript:
 We can not treat JavaScript as a full fledged programming
language. It lacks the following important features:
 Client-side JavaScript does not allow the reading or writing of
files. This has been kept for security reason.
 JavaScript can not be used for Networking applications because
there is no such support available.
 JavaScript doesn't have any multithreading or multiprocess
capabilities.
JavaScript Development Tools:
 One of JavaScript's strengths is that expensive development
tools are not usually required. You can start with a simple text
editor such as Notepad.
 Since it is an interpreted language inside the context of a web
browser, you don't even need to buy a compiler.
 To make our life simpler, various vendors have come up with
very nice JavaScript editing tools. Few of them are listed here:
– Microsoft FrontPage
– Macromedia Dreamweaver MX
– Macromedia HomeSite 5
– Yaldex Software Inc., Free JavaScript Editor
2. 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 (next slide)
<script language="javascript"
type="text/javascript">
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".
Your First JavaScript Script:
<html>
<body>
<script language="javascript"
type="text/javascript">
<!--
document.write("Hello World!")
//-->
</script>
</body>
</html>
 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
Whitespace and Line Breaks:
• JavaScript is a case-sensitive language. This means that
language keywords, variables, function names, and any other
identifiers must always be typed with a consistent capitalization
of letters.
• So identifiers Time, TIme and TIME will have different meanings
in JavaScript.
• NOTE: Care should be taken while writing your variable and
function names in JavaScript.
Case Sensitivity:
Comments in JavaScript:
• JavaScript supports both C-style and C++-style comments, Thus:
• Any text between a // and the end of a line is treated as a
comment and is ignored by JavaScript.
• Any text between the characters /* and */ is treated as a
comment. This may span multiple lines.
• JavaScript also recognizes the HTML comment opening
sequence <!--. JavaScript treats this as a single-line comment,
just as it does the // comment.
• The HTML comment closing sequence --> is not recognized by
JavaScript so it should be written as //-->.
Example 1:
<script language="javascript" type="text/javascript">
<!--
// This is a comment. It is similar to comments in C+
+
/*
* This is a multiline comment in JavaScript
* It is very similar to comments in C Programming
*/
//-->
</script>
Example 2:
<html>
<head>
<script>
function displayDate()
{
document.getElementById("demo").innerHTML=Date();
}
</script>
</head>
<body>
<h1>My First JavaScript</h1>
<p id="demo">This is a paragraph.</p>
<button type="button" onclick="displayDate()">Display
Date</button>
</body>
</html>
Ad

More Related Content

Similar to JS-Slides_for_begineers_javascript-1.ppt (20)

Basics java scripts
Basics java scriptsBasics java scripts
Basics java scripts
ch samaram
 
JAVA SCRIPT
JAVA SCRIPTJAVA SCRIPT
JAVA SCRIPT
Go4Guru
 
Js syntax
Js syntaxJs syntax
Js syntax
Sireesh K
 
Java script by Act Academy
Java script by Act AcademyJava script by Act Academy
Java script by Act Academy
actanimation
 
introduction to js
introduction to jsintroduction to js
introduction to js
Sireesh K
 
Session vii(java scriptbasics)
Session vii(java scriptbasics)Session vii(java scriptbasics)
Session vii(java scriptbasics)
Shrijan Tiwari
 
web designing course bangalore
web designing course bangaloreweb designing course bangalore
web designing course bangalore
Infocampus Logics Pvt.Ltd.
 
JS BASICS JAVA SCRIPT SCRIPTING
JS BASICS JAVA SCRIPT SCRIPTINGJS BASICS JAVA SCRIPT SCRIPTING
JS BASICS JAVA SCRIPT SCRIPTING
Arulkumar
 
2javascript web programming with JAVA script
2javascript web programming with JAVA script2javascript web programming with JAVA script
2javascript web programming with JAVA script
umardanjumamaiwada
 
CS8651- Unit 2 - JS.internet programming paper anna university -2017 regulation
CS8651- Unit 2 - JS.internet programming paper anna university -2017 regulationCS8651- Unit 2 - JS.internet programming paper anna university -2017 regulation
CS8651- Unit 2 - JS.internet programming paper anna university -2017 regulation
amrashbhanuabdul
 
Java script
Java scriptJava script
Java script
GowriLatha1
 
txWelcome to Javascript Welcome to Javascript.pp
txWelcome to Javascript Welcome to Javascript.pptxWelcome to Javascript Welcome to Javascript.pp
txWelcome to Javascript Welcome to Javascript.pp
vaibhavdtambe2003
 
t0526-2
t0526-2t0526-2
t0526-2
tutorialsruby
 
t0526-2
t0526-2t0526-2
t0526-2
tutorialsruby
 
Javascript 01 (js)
Javascript 01 (js)Javascript 01 (js)
Javascript 01 (js)
AbhishekMondal42
 
Javascript - Ebook (A Quick Guide)
Javascript - Ebook (A Quick Guide)Javascript - Ebook (A Quick Guide)
Javascript - Ebook (A Quick Guide)
sourav newatia
 
Javascript pdf for beginners easy levell
Javascript pdf for beginners easy levellJavascript pdf for beginners easy levell
Javascript pdf for beginners easy levell
SakshamGupta957136
 
WTA-MODULE-4.pptx
WTA-MODULE-4.pptxWTA-MODULE-4.pptx
WTA-MODULE-4.pptx
ChayapathiAR
 
Javascript
JavascriptJavascript
Javascript
Nagarajan
 
8.-Javascript-report powerpoint presentation
8.-Javascript-report powerpoint presentation8.-Javascript-report powerpoint presentation
8.-Javascript-report powerpoint presentation
JohnLagman3
 
Basics java scripts
Basics java scriptsBasics java scripts
Basics java scripts
ch samaram
 
JAVA SCRIPT
JAVA SCRIPTJAVA SCRIPT
JAVA SCRIPT
Go4Guru
 
Java script by Act Academy
Java script by Act AcademyJava script by Act Academy
Java script by Act Academy
actanimation
 
introduction to js
introduction to jsintroduction to js
introduction to js
Sireesh K
 
Session vii(java scriptbasics)
Session vii(java scriptbasics)Session vii(java scriptbasics)
Session vii(java scriptbasics)
Shrijan Tiwari
 
JS BASICS JAVA SCRIPT SCRIPTING
JS BASICS JAVA SCRIPT SCRIPTINGJS BASICS JAVA SCRIPT SCRIPTING
JS BASICS JAVA SCRIPT SCRIPTING
Arulkumar
 
2javascript web programming with JAVA script
2javascript web programming with JAVA script2javascript web programming with JAVA script
2javascript web programming with JAVA script
umardanjumamaiwada
 
CS8651- Unit 2 - JS.internet programming paper anna university -2017 regulation
CS8651- Unit 2 - JS.internet programming paper anna university -2017 regulationCS8651- Unit 2 - JS.internet programming paper anna university -2017 regulation
CS8651- Unit 2 - JS.internet programming paper anna university -2017 regulation
amrashbhanuabdul
 
txWelcome to Javascript Welcome to Javascript.pp
txWelcome to Javascript Welcome to Javascript.pptxWelcome to Javascript Welcome to Javascript.pp
txWelcome to Javascript Welcome to Javascript.pp
vaibhavdtambe2003
 
Javascript - Ebook (A Quick Guide)
Javascript - Ebook (A Quick Guide)Javascript - Ebook (A Quick Guide)
Javascript - Ebook (A Quick Guide)
sourav newatia
 
Javascript pdf for beginners easy levell
Javascript pdf for beginners easy levellJavascript pdf for beginners easy levell
Javascript pdf for beginners easy levell
SakshamGupta957136
 
8.-Javascript-report powerpoint presentation
8.-Javascript-report powerpoint presentation8.-Javascript-report powerpoint presentation
8.-Javascript-report powerpoint presentation
JohnLagman3
 

Recently uploaded (20)

Kenan Fellows Participants, Projects 2025-26 Cohort
Kenan Fellows Participants, Projects 2025-26 CohortKenan Fellows Participants, Projects 2025-26 Cohort
Kenan Fellows Participants, Projects 2025-26 Cohort
EducationNC
 
Contact Lens:::: An Overview.pptx.: Optometry
Contact Lens:::: An Overview.pptx.: OptometryContact Lens:::: An Overview.pptx.: Optometry
Contact Lens:::: An Overview.pptx.: Optometry
MushahidRaza8
 
GDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptxGDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptx
azeenhodekar
 
How to Manage Purchase Alternatives in Odoo 18
How to Manage Purchase Alternatives in Odoo 18How to Manage Purchase Alternatives in Odoo 18
How to Manage Purchase Alternatives in Odoo 18
Celine George
 
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
Celine George
 
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptxSCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
Ronisha Das
 
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar RabbiPresentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Md Shaifullar Rabbi
 
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - WorksheetCBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
Sritoma Majumder
 
Metamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative JourneyMetamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative Journey
Arshad Shaikh
 
Link your Lead Opportunities into Spreadsheet using odoo CRM
Link your Lead Opportunities into Spreadsheet using odoo CRMLink your Lead Opportunities into Spreadsheet using odoo CRM
Link your Lead Opportunities into Spreadsheet using odoo CRM
Celine George
 
Introduction-to-Communication-and-Media-Studies-1736283331.pdf
Introduction-to-Communication-and-Media-Studies-1736283331.pdfIntroduction-to-Communication-and-Media-Studies-1736283331.pdf
Introduction-to-Communication-and-Media-Studies-1736283331.pdf
james5028
 
2541William_McCollough_DigitalDetox.docx
2541William_McCollough_DigitalDetox.docx2541William_McCollough_DigitalDetox.docx
2541William_McCollough_DigitalDetox.docx
contactwilliamm2546
 
dynastic art of the Pallava dynasty south India
dynastic art of the Pallava dynasty south Indiadynastic art of the Pallava dynasty south India
dynastic art of the Pallava dynasty south India
PrachiSontakke5
 
apa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdfapa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdf
Ishika Ghosh
 
How to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POSHow to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POS
Celine George
 
How to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of saleHow to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of sale
Celine George
 
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
larencebapu132
 
Kasdorf "Accessibility Essentials: A 2025 NISO Training Series, Session 5, Ac...
Kasdorf "Accessibility Essentials: A 2025 NISO Training Series, Session 5, Ac...Kasdorf "Accessibility Essentials: A 2025 NISO Training Series, Session 5, Ac...
Kasdorf "Accessibility Essentials: A 2025 NISO Training Series, Session 5, Ac...
National Information Standards Organization (NISO)
 
Herbs Used in Cosmetic Formulations .pptx
Herbs Used in Cosmetic Formulations .pptxHerbs Used in Cosmetic Formulations .pptx
Herbs Used in Cosmetic Formulations .pptx
RAJU THENGE
 
SPRING FESTIVITIES - UK AND USA -
SPRING FESTIVITIES - UK AND USA            -SPRING FESTIVITIES - UK AND USA            -
SPRING FESTIVITIES - UK AND USA -
Colégio Santa Teresinha
 
Kenan Fellows Participants, Projects 2025-26 Cohort
Kenan Fellows Participants, Projects 2025-26 CohortKenan Fellows Participants, Projects 2025-26 Cohort
Kenan Fellows Participants, Projects 2025-26 Cohort
EducationNC
 
Contact Lens:::: An Overview.pptx.: Optometry
Contact Lens:::: An Overview.pptx.: OptometryContact Lens:::: An Overview.pptx.: Optometry
Contact Lens:::: An Overview.pptx.: Optometry
MushahidRaza8
 
GDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptxGDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptx
azeenhodekar
 
How to Manage Purchase Alternatives in Odoo 18
How to Manage Purchase Alternatives in Odoo 18How to Manage Purchase Alternatives in Odoo 18
How to Manage Purchase Alternatives in Odoo 18
Celine George
 
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
Celine George
 
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptxSCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
Ronisha Das
 
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar RabbiPresentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Md Shaifullar Rabbi
 
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - WorksheetCBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
Sritoma Majumder
 
Metamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative JourneyMetamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative Journey
Arshad Shaikh
 
Link your Lead Opportunities into Spreadsheet using odoo CRM
Link your Lead Opportunities into Spreadsheet using odoo CRMLink your Lead Opportunities into Spreadsheet using odoo CRM
Link your Lead Opportunities into Spreadsheet using odoo CRM
Celine George
 
Introduction-to-Communication-and-Media-Studies-1736283331.pdf
Introduction-to-Communication-and-Media-Studies-1736283331.pdfIntroduction-to-Communication-and-Media-Studies-1736283331.pdf
Introduction-to-Communication-and-Media-Studies-1736283331.pdf
james5028
 
2541William_McCollough_DigitalDetox.docx
2541William_McCollough_DigitalDetox.docx2541William_McCollough_DigitalDetox.docx
2541William_McCollough_DigitalDetox.docx
contactwilliamm2546
 
dynastic art of the Pallava dynasty south India
dynastic art of the Pallava dynasty south Indiadynastic art of the Pallava dynasty south India
dynastic art of the Pallava dynasty south India
PrachiSontakke5
 
apa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdfapa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdf
Ishika Ghosh
 
How to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POSHow to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POS
Celine George
 
How to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of saleHow to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of sale
Celine George
 
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
larencebapu132
 
Herbs Used in Cosmetic Formulations .pptx
Herbs Used in Cosmetic Formulations .pptxHerbs Used in Cosmetic Formulations .pptx
Herbs Used in Cosmetic Formulations .pptx
RAJU THENGE
 
Ad

JS-Slides_for_begineers_javascript-1.ppt

  • 1. 1. JavaScript Overview What is JavaScript ?  JavaScript started life as LiveScript, but Netscape changed the name, possibly because of the excitement being generated by Java.to JavaScript. JavaScript made its first appearance in Netscape 2.0 in 1995 with a name LiveScript.  JavaScript is a lightweight, interpreted programming language with object-oriented capabilities that allows you to build interactivity into otherwise static HTML pages.  The general-purpose core of the language has been embedded in Netscape, Internet Explorer, and other web browsers
  • 2. JavaScript is:  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
  • 3.  Client-side JavaScript is the most common form of the language. The script should be included in or referenced by an HTML document for the code to be interpreted by the browser.  It means that a web page need no longer be static HTML, but can include programs that interact with the user, control the browser, and dynamically create HTML content.  The JavaScript code is executed when the user submits the form, and only if all the entries are valid they would be submitted to the Web Server.  JavaScript can be used to trap user-initiated events such as button clicks, link navigation, and other actions that the user explicitly or implicitly initiates. Client-side JavaScript:
  • 4. Advantages of JavaScript: The merits of using JavaScript are:  Less server interaction: You can validate user input before sending the page off to the server. This saves server traffic, which means less load on your server.  Immediate feedback to the visitors: They don't have to wait for a page reload to see if they have forgotten to enter something.  Increased interactivity: You can create interfaces that react when the user hovers over them with a mouse or activates them via the keyboard.  Richer interfaces: You can use JavaScript to include such items as drag-and-drop components and sliders to give a Rich Interface to your site visitors.
  • 5. Limitations with JavaScript:  We can not treat JavaScript as a full fledged programming language. It lacks the following important features:  Client-side JavaScript does not allow the reading or writing of files. This has been kept for security reason.  JavaScript can not be used for Networking applications because there is no such support available.  JavaScript doesn't have any multithreading or multiprocess capabilities.
  • 6. JavaScript Development Tools:  One of JavaScript's strengths is that expensive development tools are not usually required. You can start with a simple text editor such as Notepad.  Since it is an interpreted language inside the context of a web browser, you don't even need to buy a compiler.  To make our life simpler, various vendors have come up with very nice JavaScript editing tools. Few of them are listed here: – Microsoft FrontPage – Macromedia Dreamweaver MX – Macromedia HomeSite 5 – Yaldex Software Inc., Free JavaScript Editor
  • 7. 2. 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 (next slide)
  • 8. <script language="javascript" type="text/javascript"> 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".
  • 9. Your First JavaScript Script: <html> <body> <script language="javascript" type="text/javascript"> <!-- document.write("Hello World!") //--> </script> </body> </html>
  • 10.  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 Whitespace and Line Breaks:
  • 11. • JavaScript is a case-sensitive language. This means that language keywords, variables, function names, and any other identifiers must always be typed with a consistent capitalization of letters. • So identifiers Time, TIme and TIME will have different meanings in JavaScript. • NOTE: Care should be taken while writing your variable and function names in JavaScript. Case Sensitivity:
  • 12. Comments in JavaScript: • JavaScript supports both C-style and C++-style comments, Thus: • Any text between a // and the end of a line is treated as a comment and is ignored by JavaScript. • Any text between the characters /* and */ is treated as a comment. This may span multiple lines. • JavaScript also recognizes the HTML comment opening sequence <!--. JavaScript treats this as a single-line comment, just as it does the // comment. • The HTML comment closing sequence --> is not recognized by JavaScript so it should be written as //-->.
  • 13. Example 1: <script language="javascript" type="text/javascript"> <!-- // This is a comment. It is similar to comments in C+ + /* * This is a multiline comment in JavaScript * It is very similar to comments in C Programming */ //--> </script>
  • 14. Example 2: <html> <head> <script> function displayDate() { document.getElementById("demo").innerHTML=Date(); } </script> </head> <body> <h1>My First JavaScript</h1> <p id="demo">This is a paragraph.</p> <button type="button" onclick="displayDate()">Display Date</button> </body> </html>