08. session 08 intoduction to javascript
TRANSCRIPT
![Page 1: 08. session 08 intoduction to javascript](https://reader034.vdocuments.mx/reader034/viewer/2022052619/5558392fd8b42ac6078b4a4b/html5/thumbnails/1.jpg)
Introduction to JavaScript
Session 8
![Page 2: 08. session 08 intoduction to javascript](https://reader034.vdocuments.mx/reader034/viewer/2022052619/5558392fd8b42ac6078b4a4b/html5/thumbnails/2.jpg)
Explain Javasript language Describe client-side and server-side
Javascript Describe build-in function
Objectives
![Page 3: 08. session 08 intoduction to javascript](https://reader034.vdocuments.mx/reader034/viewer/2022052619/5558392fd8b42ac6078b4a4b/html5/thumbnails/3.jpg)
Javascript is a language that allows you build dynamic and interactive Web pages .Javascript is a scripting language developed by Sun Microsystems and Netscape.Javascript developed from Netscape’s LivescriptClient application run in a broswer such as Netscape Navigator or Internet Explorer and Firefox
Introduction
![Page 4: 08. session 08 intoduction to javascript](https://reader034.vdocuments.mx/reader034/viewer/2022052619/5558392fd8b42ac6078b4a4b/html5/thumbnails/4.jpg)
SriptingSripting
Scripting refers to a series of commands that are interpreted and executed sequentially and immediately on an occurrence of an event
![Page 5: 08. session 08 intoduction to javascript](https://reader034.vdocuments.mx/reader034/viewer/2022052619/5558392fd8b42ac6078b4a4b/html5/thumbnails/5.jpg)
SriptingSripting Client side Scripting: Refer to a script being executed
on the client’s machine by the browser. Server side Scripting: Refer to a script being executed
on Web server to generate dynamic HTML pages.
![Page 6: 08. session 08 intoduction to javascript](https://reader034.vdocuments.mx/reader034/viewer/2022052619/5558392fd8b42ac6078b4a4b/html5/thumbnails/6.jpg)
<SCRIPT> Tag<SCRIPT> Tag The <SCRIPT> tag defines a script for an HTML
page to make them interactive There are two main purpose of the <SCRIPT> tag,
which are: Identifies a given segment of script in the HTML
page. Load an external script file .
![Page 7: 08. session 08 intoduction to javascript](https://reader034.vdocuments.mx/reader034/viewer/2022052619/5558392fd8b42ac6078b4a4b/html5/thumbnails/7.jpg)
Declaring VariableDeclaring Variable
In Javascript, the var keyword is used to create a variable by allocating memory to it.
![Page 8: 08. session 08 intoduction to javascript](https://reader034.vdocuments.mx/reader034/viewer/2022052619/5558392fd8b42ac6078b4a4b/html5/thumbnails/8.jpg)
RulesRules Javascript is a case-sensitive language. These rules are that a variable name: Can consist of digit, underscore, and alphabets. Must begin with a letter or underscore character Cannot begin with a number and cannot contain
any punctuation marks. Cannot contain any kind of special characters
such as +,*,%,and so on. Cannot contain spaces Cannot be a Javascript keyword
![Page 9: 08. session 08 intoduction to javascript](https://reader034.vdocuments.mx/reader034/viewer/2022052619/5558392fd8b42ac6078b4a4b/html5/thumbnails/9.jpg)
Data TypesData Types
![Page 10: 08. session 08 intoduction to javascript](https://reader034.vdocuments.mx/reader034/viewer/2022052619/5558392fd8b42ac6078b4a4b/html5/thumbnails/10.jpg)
Primary Data TypesPrimary Data Types
![Page 11: 08. session 08 intoduction to javascript](https://reader034.vdocuments.mx/reader034/viewer/2022052619/5558392fd8b42ac6078b4a4b/html5/thumbnails/11.jpg)
Composite Data TypesComposite Data Types A composite data type stores a collection of
multiple related values, unlike primitive data types.
![Page 12: 08. session 08 intoduction to javascript](https://reader034.vdocuments.mx/reader034/viewer/2022052619/5558392fd8b42ac6078b4a4b/html5/thumbnails/12.jpg)
““null “ Keywordnull “ Keyword The null keyword specifies that a variable does
not hold any value. (the null value is not equal to zero because zero is a calculate value while null refers to the absence of a value)
![Page 13: 08. session 08 intoduction to javascript](https://reader034.vdocuments.mx/reader034/viewer/2022052619/5558392fd8b42ac6078b4a4b/html5/thumbnails/13.jpg)
Methods to displayMethods to display Javascript allows you to display information
using the methods of the document object . The document object is a predefined object in
Javascriptwrite () : display any type of datawriteln(): Display any type of data and appends a new line character.
![Page 14: 08. session 08 intoduction to javascript](https://reader034.vdocuments.mx/reader034/viewer/2022052619/5558392fd8b42ac6078b4a4b/html5/thumbnails/14.jpg)
Comments Comments JavaScript support two types of comments. There
are: Single - line comments Multi - line comments
![Page 15: 08. session 08 intoduction to javascript](https://reader034.vdocuments.mx/reader034/viewer/2022052619/5558392fd8b42ac6078b4a4b/html5/thumbnails/15.jpg)
Esccap Sequences CharacterEsccap Sequences Character There are multiple escape sequence characters in
Javascript that provides various kind of formatting.
![Page 16: 08. session 08 intoduction to javascript](https://reader034.vdocuments.mx/reader034/viewer/2022052619/5558392fd8b42ac6078b4a4b/html5/thumbnails/16.jpg)
Built –in FunctionBuilt –in Function
![Page 17: 08. session 08 intoduction to javascript](https://reader034.vdocuments.mx/reader034/viewer/2022052619/5558392fd8b42ac6078b4a4b/html5/thumbnails/17.jpg)
JavaScript KeywordsKeywords are predefined terms that can not be used as an object name, function name or variable name
JavaScript Keyword
break case comment
continue default delete
do else export
for function if
import in Label
new return switch
this typeof var
void while with
![Page 18: 08. session 08 intoduction to javascript](https://reader034.vdocuments.mx/reader034/viewer/2022052619/5558392fd8b42ac6078b4a4b/html5/thumbnails/18.jpg)
Build-in FunctionsFunction Description Example
toFixed Specifies the number of digits to be displayed after the decimal point
var price = 23.456;var fixedprice = price.toFixed(2)return 23.46
toPrecision Specifies the number of digits to be displayed from a given number
var price = 45.9431alert(price. toPrecision(3))return 45.9
toString Convert any value into a string value
var age=25;alert(‘Age:’ + age.toString()+’years’)Return Age: 25 years
![Page 19: 08. session 08 intoduction to javascript](https://reader034.vdocuments.mx/reader034/viewer/2022052619/5558392fd8b42ac6078b4a4b/html5/thumbnails/19.jpg)
Summary The Javascript runtime engine reads and
executes the Javascript code either on the server or in the browser.
The Server element includes JavaScript code, which is executed by the Web Server.
The NOSCRIPT element specifies the alternate content to be displayed, if the browser closes not support Javascript.
![Page 20: 08. session 08 intoduction to javascript](https://reader034.vdocuments.mx/reader034/viewer/2022052619/5558392fd8b42ac6078b4a4b/html5/thumbnails/20.jpg)
Summary… Javascript provides various keywords: break, if,
continue, new, this… The toFixed() function that specifies the number
of digits to be displayed after the decimal point. The toPrecision() function specifies the number
of digits in a number to be displayed to the user. The toString() function transforms a value into
string.
Building Dynamic Websites/Session 1/ 20 of 16