SlideServe
Menu
Préférences
© SlideServe · v2026

Understanding JavaScript: Syntax and Usage in HTML Documents

clark-bartlett avatar
12 diapositives · 267 Views · Nov 04, 2014

This lecture introduces JavaScript, a versatile client-side programming language that runs in modern web browsers. Unlike traditional languages such as C++ and Java, JavaScript is interpreted and does not require compilation. You'll learn how to insert JavaScript code into HTML documents, both in the `` and `` sections, and understand the significance of the `` tag. Additionally, the lecture covers JavaScript syntax, variable declaration, and the similarities with C++ and Java, providing a clear foundation for beginners.

Understanding JavaScript: Syntax and Usage in HTML Documents - slide 1
01 / 12Understanding JavaScript: Syntax and Usage in HTML Documents
1 / 17

Télécharger la présentation

Understanding JavaScript: Syntax and Usage in HTML Documents
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. Lecture 8: JavaScript JavaScript Syntax, how to use it in a HTML document

  2. What is JavaScript • JavaScript is a programming language that can be executed in almost every modern browser. • It is different from traditional programming language such as C++, Java. • It is a interpreted or scripting language. • Do not need to be compiled before execution. • Must be executed by an interpreter. A browser contains a JavaScript interpreter.

  3. What is JavaScript • JavaScript is client-side programming language. • It is executed in the browser of a client, not on a web server. • It allows interaction on client side. • For example, an image can be changed to another when a user moves his mouse over the image.

  4. How to use JavaScript • JavaScript code can be inserted into a HTML file. • In both <head> and <body> • For example <head> <title>JS Hello World</title> <script type="text/javascript"> window.alert("Hello World"); </script> </head>

  5. How to use JavaScript • You can insert JavaScript in <body> as well • For example <body> <script type="text/javascript"> window.alert("Hello World"); </script> </body>

  6. How to use JavaScript • JavaScript code in HTML must be inside the <script> tag. • JavaScript can be also included from external sources using <script> tag. • Just put the following into <head> tag • <script type="text/javascript” src=“filename.js>

  7. How to use JavaScript • JavaScript code in HTML must be inside the <script> tag. • JavaScript can be also included from external sources using <script> tag. • Just put the following into <head> tag • <script type="text/javascript” src=“filename.js>

  8. JavaScript Syntax • Every JavaScript statement must end with a semicolon ; • If it is inside a HTML file, JavaScript must be inside the <script> tag • For example, <script> var number = 10; //declare a variable named number <script>

  9. JavaScript Syntax • JavaScript’s basic syntax is identical to that of C++ and Java. • // begins a comment that ends at the end of the line • /* and */ may be used to contain multiline comments • For instance //This is number 1 /*I assigned 10 to the variable number.*/

  10. JavaScript Syntax • Variables names are case sensitive. • JavaScript does not have typed variables. • The variable declarations do not specify a data type for the variables • When you declare a variable, always start with keyword var var num1 = 10; var Num1 = 20; //this is ok because of case sensitivity var color = ‘c’; varfirstname = “David”

  11. JavaScript Syntax • Similarities between JavaScript and C++. • Most of operators are the same as in Java and C++ • !=, +, &, /, %, >, < • JavaScript uses braces to enclose statement blocks and its syntax for assignment (=) and control statements (if, while) are the same as in Java and C++.

  12. Next class • Variables and Data Types • Statements • Expression • Block statement • Keyword statement • Operators • +, -, *, /, %, ==, ++, --, <, >, etc