Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Chapter 2 - JavaScript Syntax, Exercises of Javascript programming

JavaScript semicolons are optional. It does not strictly require semicolons. Case Sensitivity. JavaScript is a case-sensitive language.

Typology: Exercises

2022/2023

Uploaded on 03/01/2023

faylin
faylin šŸ‡ŗšŸ‡ø

4.9

(8)

225 documents

1 / 7

Toggle sidebar

Related documents


Partial preview of the text

Download Chapter 2 - JavaScript Syntax and more Exercises Javascript programming in PDF only on Docsity! Chapter 2 - JavaScript Syntax JavaScript syntax refers to the set of rules that determine how JavaScript programs are built by the programmer and interpreted by the browser. <script>ā€¦ā€¦. </script> Html tag is use to implantation of JavaScript statements. You can place the <script> tags, which contain your JavaScript, anywhere on your web page, but it is usually recommended that you keep it in the <head> tags. Or we can add that <script> tag to the bottom of the file outside to the Html or in the <body> tag of the Html code. There are two ways to add JavaScript in HTML. 1. Embed JavaScript in HTML JavaScript code will be written as follows: <script> JavaScript Code </script> And the alternate way is 2. External JavaScript File This makes editing the code much easier for the programmer. ā€˜srcā€™ , ā€˜typeā€™ and ā€˜languageā€™ are most common attributes of <script> tag. <script language =ā€javascriptā€ src= ā€œmy_file.jsā€ type= ā€œtext/javascriptā€> </script> Syntax Basics Understanding statements, variable naming, whitespace, and other basic JavaScript syntax. Variable Life Cycle Simple variable declaration B) Multi line Comment Semicolons JavaScript semicolons are optional. It does not strictly require semicolons. Case Sensitivity JavaScript is a case-sensitive language. This means that keywords, function names variables and any other identifiers must always be typed with a consistent capitalization of letters. For example: 1) The ā€˜returnā€™ keyword, must be typed ā€œreturnā€, not ā€œReturnā€ or ā€œRETURNā€. 2) First JavaScript Code Let us take a simple example to print message ā€œHello Worldā€. Code 1)Put <script> into the head section. 2)Put <script> tag to the bottom of head section. Peel a ee) eee on seer es eee eat rem nun Pree nerne ea=2Reer) DOCTYPE html Sets gata Cd Cire irate caetaee 7 cere script: Output Ā© tye x + SL SD Mile eyhservAmiyMocumenrs/evescipt/elle wordne| Qe Ā¢ eh 8 Hello World