SlideShare una empresa de Scribd logo
1 de 20
Descargar para leer sin conexión
JAVASCRIPT
Week 9, Day 1
Introduction to Scripting
• Scripting Languages are mainly used to build the programming environment in
HTML document .It Makes Web pages dynamic and interactive.
• There are 2 types of scripting languages
• Client side scripting languages
• Are scripts that execute on client side or the browser. Browser Includes
Scripting Interpreter
• Eg: VBScript, JavaScript, Jscript and ECMA Script
• Server side scripting languages
• Are scripts that execute on server side
• Eg: PHP,JSP, ASP .NET
Features of JavaScript
 C-based language developed by Netscape
 Mainly used for client side scripting because it is supported by all
the browsers.
 Platform Independence
 JavaScript is NOT supported by old browsers (IE 1.0). You can
enable or disable JS in new browsers
How to start programming in JavaScript
• All JavaScript Code must be in between the below tags
<script>
// JavaScript Code goes here
</script>
How to start programming in JavaScript
• JavaScript can be embedded to any HTML code in two ways
–Immediate scripting
–Deferred Scripting
Immediate Mode Scripting
• SCRIPT tag can be placed in HEAD or BODY tag
• Placing JavaScript in the HEAD tag ensures readability.
• Scripts gets executed as the page loads.
<body>
<h4> Immediate Demo</h4>
<script language="JavaScript">
document.write("<h5> Using JavaScript</h5>");
</script>
</body>
<script language="JavaScript">
/*calling function when user clicks on the button */
function msg(){
alert("Hi");
}
</script>
<form name="f1">
<input type="button" value=" ok " onClick="msg()">
</form>
Deferred Mode Scripting
–Script is executed based on some user action
JavaScript – lexical structure
• JavaScript is object based and action-oriented.
• JavaScript is case sensitive.
• A semicolon ends a JavaScript statement
Commenting
C
// comment single line
/* comment
multiple lines */
JavaScript
//comment single line
/* Comment
multiple Lines*/
Declaring a variable
C
//Declaring a variable
Int a=10;
Char c=‘a’;
Float f=1.12;
JavaScript
//No need of prior Declarations
Var a=10; //local
b=15; //global
Variables in Detail
• Must start with a letter or an underscore and can have digits.
• The Data type is automatically decided by the usage.
• Scope is by default global. If a variable is prefixed by the keyword ‚var‛
within a function then it is a local variable.
• The formal parameters are local to the function.
function demo()
{
var inum1 = 10; // Local to the function
inum2 = 20; // Global to the document.
}
demo(); // Invoking function
inum1 = inum1+1; // Error because inum1 is local variable
inum2 = inum2+1; // no Error
JavaScript – Implicit data types
• JavaScript recognizes the following implicit data types
– Number
– String
– Logical
– Object
– The special value null
• Type conversion
– JavaScript automatically converts between data types
str = ‚100‛, num1 = 10, num2 = 20
num3 = num1+ num2
strsum = str + num2
strsum = num2 + str
30
10020
20100
Output
C
Int a=10,b=25;
Printf(‚%d %d‛,a,b);
JavaScript
Var a=10; var b=25;
Document.write(a,b);
Control Structures
C
Conditional Control Structures
• If
• If else
• Switch
Loops
• For
• While
• Do while
JavaScript
‚Exactly the same as on left side‛
Functions
C
Int findSum(int a,int b)
{
Int c;
c=a+b;
Return c
}
findSum(10,15);
JavaScript
function findSum(a,b)
{
c=a+b;
Return c;
}
findSum(10,15);
Operators
C
Arithmetic Operators
+, ++, -, --, *, /, %
Relational Operators
==, !=, ===, !==, >, >=, < , <=
Logical Operators
&&, ||, !
Assignment Operators
=, +=, -=, *=, /=, %=
Strict equal (===)
Strict not equal (!==)
Returns true if the operands are not
equal and/or not of the same type.
JavaScript
‚Exactly the same as on left side‛
Dialog boxes (Window Object methods)
• Alert dialog box - alert(message)
– Takes in a string argument and displays an alert box.
• Prompt dialog box - prompt(message,[inputDefault])
– Displays a message and a data entry field
• Confirm dialog box - confirm(message )
– Serves as a technique for confirming user actions
Questions?
‚A good question deserve a good grade…‛
End of Day
Contact Us
Emarald Mall (Big Bazar Building)
Mavoor Road, Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25 550
NC Complex, Near Bus Stand
Mukkam, Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25 550
Start up Village
Eranakulam,
Kerala, India.
Email: info@baabtra.com

Más contenido relacionado

La actualidad más candente

Flow-based programming with Elixir
Flow-based programming with ElixirFlow-based programming with Elixir
Flow-based programming with ElixirAnton Mishchuk
 
Intro to elixir metaprogramming
Intro to elixir metaprogrammingIntro to elixir metaprogramming
Intro to elixir metaprogrammingAnton Mishchuk
 
Flowex - Railway Flow-Based Programming with Elixir GenStage.
Flowex - Railway Flow-Based Programming with Elixir GenStage.Flowex - Railway Flow-Based Programming with Elixir GenStage.
Flowex - Railway Flow-Based Programming with Elixir GenStage.Anton Mishchuk
 
Workshop Intro: FrontEnd General Overview
Workshop Intro: FrontEnd General OverviewWorkshop Intro: FrontEnd General Overview
Workshop Intro: FrontEnd General OverviewVisual Engineering
 
Small eigen collider
Small eigen colliderSmall eigen collider
Small eigen colliderAndrew Grimm
 
Introduction to javaScript
Introduction to javaScriptIntroduction to javaScript
Introduction to javaScriptNeil Ghosh
 
Thinking in Components
Thinking in ComponentsThinking in Components
Thinking in ComponentsAnton Ivanov
 
Elm: Make Yourself A Happy Front-end Web Developer
Elm: Make Yourself A Happy Front-end Web DeveloperElm: Make Yourself A Happy Front-end Web Developer
Elm: Make Yourself A Happy Front-end Web DeveloperAsep Bagja
 

La actualidad más candente (15)

Js syntax
Js syntaxJs syntax
Js syntax
 
JavaScript Basics
JavaScript BasicsJavaScript Basics
JavaScript Basics
 
Flow-based programming with Elixir
Flow-based programming with ElixirFlow-based programming with Elixir
Flow-based programming with Elixir
 
Java scriptforjavadev part1
Java scriptforjavadev part1Java scriptforjavadev part1
Java scriptforjavadev part1
 
Intro to elixir metaprogramming
Intro to elixir metaprogrammingIntro to elixir metaprogramming
Intro to elixir metaprogramming
 
Js in quick books
Js in quick booksJs in quick books
Js in quick books
 
JS Event Loop
JS Event LoopJS Event Loop
JS Event Loop
 
Flowex - Railway Flow-Based Programming with Elixir GenStage.
Flowex - Railway Flow-Based Programming with Elixir GenStage.Flowex - Railway Flow-Based Programming with Elixir GenStage.
Flowex - Railway Flow-Based Programming with Elixir GenStage.
 
Workshop Intro: FrontEnd General Overview
Workshop Intro: FrontEnd General OverviewWorkshop Intro: FrontEnd General Overview
Workshop Intro: FrontEnd General Overview
 
Small eigen collider
Small eigen colliderSmall eigen collider
Small eigen collider
 
JavaScript | Introduction
JavaScript | IntroductionJavaScript | Introduction
JavaScript | Introduction
 
Introduction to javaScript
Introduction to javaScriptIntroduction to javaScript
Introduction to javaScript
 
Web application
Web applicationWeb application
Web application
 
Thinking in Components
Thinking in ComponentsThinking in Components
Thinking in Components
 
Elm: Make Yourself A Happy Front-end Web Developer
Elm: Make Yourself A Happy Front-end Web DeveloperElm: Make Yourself A Happy Front-end Web Developer
Elm: Make Yourself A Happy Front-end Web Developer
 

Similar a Javascript

Java script.pptx v
Java script.pptx                                     vJava script.pptx                                     v
Java script.pptx v22x026
 
Iwt note(module 2)
Iwt note(module 2)Iwt note(module 2)
Iwt note(module 2)SANTOSH RATH
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to Javascriptambuj pathak
 
JavaScript New Tutorial Class XI and XII.pptx
JavaScript New Tutorial Class XI and XII.pptxJavaScript New Tutorial Class XI and XII.pptx
JavaScript New Tutorial Class XI and XII.pptxrish15r890
 
8.-Javascript-report powerpoint presentation
8.-Javascript-report powerpoint presentation8.-Javascript-report powerpoint presentation
8.-Javascript-report powerpoint presentationJohnLagman3
 
Basic Java script handouts for students
Basic Java script handouts for students Basic Java script handouts for students
Basic Java script handouts for students shafiq sangi
 
Unit 4 Java script.pptx
Unit 4 Java script.pptxUnit 4 Java script.pptx
Unit 4 Java script.pptxGangesh8
 
IT2255 Web Essentials - Unit III Client-Side Processing and Scripting
IT2255 Web Essentials - Unit III Client-Side Processing and ScriptingIT2255 Web Essentials - Unit III Client-Side Processing and Scripting
IT2255 Web Essentials - Unit III Client-Side Processing and Scriptingpkaviya
 
Javascript tutorial basic for starter
Javascript tutorial basic for starterJavascript tutorial basic for starter
Javascript tutorial basic for starterMarcello Harford
 

Similar a Javascript (20)

Java scipt
Java sciptJava scipt
Java scipt
 
Client sidescripting javascript
Client sidescripting javascriptClient sidescripting javascript
Client sidescripting javascript
 
Java script.pptx v
Java script.pptx                                     vJava script.pptx                                     v
Java script.pptx v
 
Iwt note(module 2)
Iwt note(module 2)Iwt note(module 2)
Iwt note(module 2)
 
ASP.NET Basics
ASP.NET Basics ASP.NET Basics
ASP.NET Basics
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to Javascript
 
JavaScript_III.pptx
JavaScript_III.pptxJavaScript_III.pptx
JavaScript_III.pptx
 
JavaScripts & jQuery
JavaScripts & jQueryJavaScripts & jQuery
JavaScripts & jQuery
 
Unit 4(it workshop)
Unit 4(it workshop)Unit 4(it workshop)
Unit 4(it workshop)
 
Java script
Java scriptJava script
Java script
 
JavaScript New Tutorial Class XI and XII.pptx
JavaScript New Tutorial Class XI and XII.pptxJavaScript New Tutorial Class XI and XII.pptx
JavaScript New Tutorial Class XI and XII.pptx
 
8.-Javascript-report powerpoint presentation
8.-Javascript-report powerpoint presentation8.-Javascript-report powerpoint presentation
8.-Javascript-report powerpoint presentation
 
Javascript
JavascriptJavascript
Javascript
 
Basic Java script handouts for students
Basic Java script handouts for students Basic Java script handouts for students
Basic Java script handouts for students
 
Unit 4 Java script.pptx
Unit 4 Java script.pptxUnit 4 Java script.pptx
Unit 4 Java script.pptx
 
Java script
Java scriptJava script
Java script
 
Javascript tutorial
Javascript tutorialJavascript tutorial
Javascript tutorial
 
3. Java Script
3. Java Script3. Java Script
3. Java Script
 
IT2255 Web Essentials - Unit III Client-Side Processing and Scripting
IT2255 Web Essentials - Unit III Client-Side Processing and ScriptingIT2255 Web Essentials - Unit III Client-Side Processing and Scripting
IT2255 Web Essentials - Unit III Client-Side Processing and Scripting
 
Javascript tutorial basic for starter
Javascript tutorial basic for starterJavascript tutorial basic for starter
Javascript tutorial basic for starter
 

Más de baabtra.com - No. 1 supplier of quality freshers

Más de baabtra.com - No. 1 supplier of quality freshers (20)

Agile methodology and scrum development
Agile methodology and scrum developmentAgile methodology and scrum development
Agile methodology and scrum development
 
Best coding practices
Best coding practicesBest coding practices
Best coding practices
 
Core java - baabtra
Core java - baabtraCore java - baabtra
Core java - baabtra
 
Acquiring new skills what you should know
Acquiring new skills   what you should knowAcquiring new skills   what you should know
Acquiring new skills what you should know
 
Baabtra.com programming at school
Baabtra.com programming at schoolBaabtra.com programming at school
Baabtra.com programming at school
 
99LMS for Enterprises - LMS that you will love
99LMS for Enterprises - LMS that you will love 99LMS for Enterprises - LMS that you will love
99LMS for Enterprises - LMS that you will love
 
Php sessions & cookies
Php sessions & cookiesPhp sessions & cookies
Php sessions & cookies
 
Php database connectivity
Php database connectivityPhp database connectivity
Php database connectivity
 
Chapter 6 database normalisation
Chapter 6  database normalisationChapter 6  database normalisation
Chapter 6 database normalisation
 
Chapter 5 transactions and dcl statements
Chapter 5  transactions and dcl statementsChapter 5  transactions and dcl statements
Chapter 5 transactions and dcl statements
 
Chapter 4 functions, views, indexing
Chapter 4  functions, views, indexingChapter 4  functions, views, indexing
Chapter 4 functions, views, indexing
 
Chapter 3 stored procedures
Chapter 3 stored proceduresChapter 3 stored procedures
Chapter 3 stored procedures
 
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
Chapter 2  grouping,scalar and aggergate functions,joins   inner join,outer joinChapter 2  grouping,scalar and aggergate functions,joins   inner join,outer join
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
 
Microsoft holo lens
Microsoft holo lensMicrosoft holo lens
Microsoft holo lens
 
Blue brain
Blue brainBlue brain
Blue brain
 
5g
5g5g
5g
 
Aptitude skills baabtra
Aptitude skills baabtraAptitude skills baabtra
Aptitude skills baabtra
 
Gd baabtra
Gd baabtraGd baabtra
Gd baabtra
 

Último

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 

Último (20)

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

Javascript

  • 2. Introduction to Scripting • Scripting Languages are mainly used to build the programming environment in HTML document .It Makes Web pages dynamic and interactive. • There are 2 types of scripting languages • Client side scripting languages • Are scripts that execute on client side or the browser. Browser Includes Scripting Interpreter • Eg: VBScript, JavaScript, Jscript and ECMA Script • Server side scripting languages • Are scripts that execute on server side • Eg: PHP,JSP, ASP .NET
  • 3. Features of JavaScript  C-based language developed by Netscape  Mainly used for client side scripting because it is supported by all the browsers.  Platform Independence  JavaScript is NOT supported by old browsers (IE 1.0). You can enable or disable JS in new browsers
  • 4. How to start programming in JavaScript • All JavaScript Code must be in between the below tags <script> // JavaScript Code goes here </script>
  • 5. How to start programming in JavaScript • JavaScript can be embedded to any HTML code in two ways –Immediate scripting –Deferred Scripting
  • 6. Immediate Mode Scripting • SCRIPT tag can be placed in HEAD or BODY tag • Placing JavaScript in the HEAD tag ensures readability. • Scripts gets executed as the page loads. <body> <h4> Immediate Demo</h4> <script language="JavaScript"> document.write("<h5> Using JavaScript</h5>"); </script> </body>
  • 7. <script language="JavaScript"> /*calling function when user clicks on the button */ function msg(){ alert("Hi"); } </script> <form name="f1"> <input type="button" value=" ok " onClick="msg()"> </form> Deferred Mode Scripting –Script is executed based on some user action
  • 8. JavaScript – lexical structure • JavaScript is object based and action-oriented. • JavaScript is case sensitive. • A semicolon ends a JavaScript statement
  • 9. Commenting C // comment single line /* comment multiple lines */ JavaScript //comment single line /* Comment multiple Lines*/
  • 10. Declaring a variable C //Declaring a variable Int a=10; Char c=‘a’; Float f=1.12; JavaScript //No need of prior Declarations Var a=10; //local b=15; //global
  • 11. Variables in Detail • Must start with a letter or an underscore and can have digits. • The Data type is automatically decided by the usage. • Scope is by default global. If a variable is prefixed by the keyword ‚var‛ within a function then it is a local variable. • The formal parameters are local to the function. function demo() { var inum1 = 10; // Local to the function inum2 = 20; // Global to the document. } demo(); // Invoking function inum1 = inum1+1; // Error because inum1 is local variable inum2 = inum2+1; // no Error
  • 12. JavaScript – Implicit data types • JavaScript recognizes the following implicit data types – Number – String – Logical – Object – The special value null • Type conversion – JavaScript automatically converts between data types str = ‚100‛, num1 = 10, num2 = 20 num3 = num1+ num2 strsum = str + num2 strsum = num2 + str 30 10020 20100
  • 14. Control Structures C Conditional Control Structures • If • If else • Switch Loops • For • While • Do while JavaScript ‚Exactly the same as on left side‛
  • 15. Functions C Int findSum(int a,int b) { Int c; c=a+b; Return c } findSum(10,15); JavaScript function findSum(a,b) { c=a+b; Return c; } findSum(10,15);
  • 16. Operators C Arithmetic Operators +, ++, -, --, *, /, % Relational Operators ==, !=, ===, !==, >, >=, < , <= Logical Operators &&, ||, ! Assignment Operators =, +=, -=, *=, /=, %= Strict equal (===) Strict not equal (!==) Returns true if the operands are not equal and/or not of the same type. JavaScript ‚Exactly the same as on left side‛
  • 17. Dialog boxes (Window Object methods) • Alert dialog box - alert(message) – Takes in a string argument and displays an alert box. • Prompt dialog box - prompt(message,[inputDefault]) – Displays a message and a data entry field • Confirm dialog box - confirm(message ) – Serves as a technique for confirming user actions
  • 18. Questions? ‚A good question deserve a good grade…‛
  • 20. Contact Us Emarald Mall (Big Bazar Building) Mavoor Road, Kozhikode, Kerala, India. Ph: + 91 – 495 40 25 550 NC Complex, Near Bus Stand Mukkam, Kozhikode, Kerala, India. Ph: + 91 – 495 40 25 550 Start up Village Eranakulam, Kerala, India. Email: info@baabtra.com