SlideShare uma empresa Scribd logo
1 de 12
Javascript Survival for Honesty and Humility What is Javascript? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],What can a JavaScript do? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Program Example: <html> <body> <script type=&quot;text/javascript&quot;> document.write(&quot;Hello World!&quot;); </script> </body> </html>  Output:
Where to put Javascript? Javascript in a page will be executed immediately while the page loads into the browser. This is not always what we want. Sometimes we want to execute a script when a page loads, or at a later event, such as when a user clicks a button.  a. Scripts in <head> <html> <head> <script type=&quot;text/javascript&quot;> function message() { alert(&quot;This alert box was called with the onload event&quot;); } </script> </head> <body onload=&quot;message()&quot;> </body> </html>  Input Program:   Output Program:
b. Scripts in <body> Input Program:   Output Program: <html> <head> </head> <body> <script type=&quot;text/javascript&quot;> document.write(&quot;This message is written by JavaScript&quot;); </script> </body> </html>
c. Scripts in <head> and <body> Input Program:   Output Program: <html> <head> <script type=&quot;text/javascript&quot;> function message() { alert(&quot;This alert box was called with the onload event&quot;); } </script> </head> <body onload=&quot;message()&quot;> <script type=&quot;text/javascript&quot;> document.write(&quot;This message is written by JavaScript&quot;); </script> </body> </html>
Rules in Javascript ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Javascript Variables As with algebra, JavaScript variables are used to hold values or expressions. A variable can have a short name, like x, or a more descriptive name, like carname. Rules for JavaScript variable names: Variable names are case sensitive (y and Y are two different variables)  Variable names must begin with a letter or the underscore character  Note:  Because JavaScript is case-sensitive, variable names are case-sensitive. Declaring (or creating) Javascript Variables var x; var carname;  Assigning Values to Undeclare Javascript Variables var x=5; var carname=“Toyota”;  var x=5; var carname=“Toyota”;  You can use the assigned values when you declare them:  x=5; carname=“Toyota”;  has same effect as…
Redeclaring Javascript Variables var x=5; var x;  After the execution of the statements above, the variable x will still have the value of 5. The value of x is not reset (or cleared) when you redeclare it.  Javascript Arithmetic y=x-5; z=y+3;
Javascript  Arithmetic Operators
Javascript  Assignment Operators
The + Operator Used on Strings txt1=&quot;What a very&quot;; txt2=&quot;nice day&quot;; txt3=txt1+txt2; Input Program:   Output Program: What a very nice day Comparison Operators
Logical Operators Syntax: variablename=(condition)?value1:value2  Example: greeting=(visitor==&quot;PRES&quot;)?&quot;Dear President &quot;:&quot;Dear &quot;; Result: “ Dear President” or else “Dear” Conditional Operators

Mais conteúdo relacionado

Mais procurados

Web topic 21 pass info via javascript
Web topic 21  pass info via javascriptWeb topic 21  pass info via javascript
Web topic 21 pass info via javascript
CK Yang
 
Introduction to javaScript
Introduction to javaScriptIntroduction to javaScript
Introduction to javaScript
Neil Ghosh
 
Coder Presentation
Coder  PresentationCoder  Presentation
Coder Presentation
Doug Green
 

Mais procurados (20)

Java scripts
Java scriptsJava scripts
Java scripts
 
Java Script
Java ScriptJava Script
Java Script
 
Unit 2.4
Unit 2.4Unit 2.4
Unit 2.4
 
Java script
Java scriptJava script
Java script
 
Basics of Javascript
Basics of Javascript Basics of Javascript
Basics of Javascript
 
JavaScript - Part-1
JavaScript - Part-1JavaScript - Part-1
JavaScript - Part-1
 
HTML Introduction
HTML IntroductionHTML Introduction
HTML Introduction
 
Razor new view engine asp.net
Razor new view engine asp.netRazor new view engine asp.net
Razor new view engine asp.net
 
Javascript
JavascriptJavascript
Javascript
 
Introduction to Java Script
Introduction to Java ScriptIntroduction to Java Script
Introduction to Java Script
 
Scripting languages
Scripting languagesScripting languages
Scripting languages
 
JavaScript Introduction
JavaScript IntroductionJavaScript Introduction
JavaScript Introduction
 
Client side scripting
Client side scriptingClient side scripting
Client side scripting
 
Java script
Java scriptJava script
Java script
 
Web topic 21 pass info via javascript
Web topic 21  pass info via javascriptWeb topic 21  pass info via javascript
Web topic 21 pass info via javascript
 
Java script
Java scriptJava script
Java script
 
Introduction to javaScript
Introduction to javaScriptIntroduction to javaScript
Introduction to javaScript
 
Java Servlets Part 2
Java Servlets Part 2Java Servlets Part 2
Java Servlets Part 2
 
Java script
Java scriptJava script
Java script
 
Coder Presentation
Coder  PresentationCoder  Presentation
Coder Presentation
 

Destaque (6)

ศิลปะฉับพลัน54
ศิลปะฉับพลัน54ศิลปะฉับพลัน54
ศิลปะฉับพลัน54
 
Third year CSBN presentation 2nd quarter - flash gui
Third year CSBN presentation   2nd quarter - flash guiThird year CSBN presentation   2nd quarter - flash gui
Third year CSBN presentation 2nd quarter - flash gui
 
Bērnu žūrija 2010
Bērnu žūrija 2010Bērnu žūrija 2010
Bērnu žūrija 2010
 
Javascript survival2
Javascript survival2Javascript survival2
Javascript survival2
 
Jason Javier- Hero
Jason Javier- HeroJason Javier- Hero
Jason Javier- Hero
 
กลุ่ม54 ศิลปะฉับพลัน
กลุ่ม54  ศิลปะฉับพลันกลุ่ม54  ศิลปะฉับพลัน
กลุ่ม54 ศิลปะฉับพลัน
 

Semelhante a Javascript survival for CSBN Sophomores

Semelhante a Javascript survival for CSBN Sophomores (20)

Introduction to Java Scripting
Introduction to Java ScriptingIntroduction to Java Scripting
Introduction to Java Scripting
 
Introduction to java script
Introduction to java scriptIntroduction to java script
Introduction to java script
 
Javascript
JavascriptJavascript
Javascript
 
Jquery 1
Jquery 1Jquery 1
Jquery 1
 
Javascript
JavascriptJavascript
Javascript
 
Unit 2.4
Unit 2.4Unit 2.4
Unit 2.4
 
JavaScript & Dom Manipulation
JavaScript & Dom ManipulationJavaScript & Dom Manipulation
JavaScript & Dom Manipulation
 
Web programming
Web programmingWeb programming
Web programming
 
Javascript tutorial
Javascript tutorialJavascript tutorial
Javascript tutorial
 
Java script Basic
Java script BasicJava script Basic
Java script Basic
 
Tugas Pw [6]
Tugas Pw [6]Tugas Pw [6]
Tugas Pw [6]
 
Tugas Pw [6] (2)
Tugas Pw [6] (2)Tugas Pw [6] (2)
Tugas Pw [6] (2)
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to Javascript
 
JavaScript - Getting Started.pptx
JavaScript - Getting Started.pptxJavaScript - Getting Started.pptx
JavaScript - Getting Started.pptx
 
JavaScript
JavaScriptJavaScript
JavaScript
 
Java script by Act Academy
Java script by Act AcademyJava script by Act Academy
Java script by Act Academy
 
JavaScript_III.pptx
JavaScript_III.pptxJavaScript_III.pptx
JavaScript_III.pptx
 
Java scipt
Java sciptJava scipt
Java scipt
 
Basic Java script handouts for students
Basic Java script handouts for students Basic Java script handouts for students
Basic Java script handouts for students
 
JavaScript with Syntax & Implementation
JavaScript with Syntax & ImplementationJavaScript with Syntax & Implementation
JavaScript with Syntax & Implementation
 

Último

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
negromaestrong
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
AnaAcapella
 

Último (20)

Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Magic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxMagic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptx
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 

Javascript survival for CSBN Sophomores

  • 1.
  • 2. Program Example: <html> <body> <script type=&quot;text/javascript&quot;> document.write(&quot;Hello World!&quot;); </script> </body> </html> Output:
  • 3. Where to put Javascript? Javascript in a page will be executed immediately while the page loads into the browser. This is not always what we want. Sometimes we want to execute a script when a page loads, or at a later event, such as when a user clicks a button. a. Scripts in <head> <html> <head> <script type=&quot;text/javascript&quot;> function message() { alert(&quot;This alert box was called with the onload event&quot;); } </script> </head> <body onload=&quot;message()&quot;> </body> </html> Input Program: Output Program:
  • 4. b. Scripts in <body> Input Program: Output Program: <html> <head> </head> <body> <script type=&quot;text/javascript&quot;> document.write(&quot;This message is written by JavaScript&quot;); </script> </body> </html>
  • 5. c. Scripts in <head> and <body> Input Program: Output Program: <html> <head> <script type=&quot;text/javascript&quot;> function message() { alert(&quot;This alert box was called with the onload event&quot;); } </script> </head> <body onload=&quot;message()&quot;> <script type=&quot;text/javascript&quot;> document.write(&quot;This message is written by JavaScript&quot;); </script> </body> </html>
  • 6.
  • 7. Javascript Variables As with algebra, JavaScript variables are used to hold values or expressions. A variable can have a short name, like x, or a more descriptive name, like carname. Rules for JavaScript variable names: Variable names are case sensitive (y and Y are two different variables) Variable names must begin with a letter or the underscore character Note: Because JavaScript is case-sensitive, variable names are case-sensitive. Declaring (or creating) Javascript Variables var x; var carname; Assigning Values to Undeclare Javascript Variables var x=5; var carname=“Toyota”; var x=5; var carname=“Toyota”; You can use the assigned values when you declare them: x=5; carname=“Toyota”; has same effect as…
  • 8. Redeclaring Javascript Variables var x=5; var x; After the execution of the statements above, the variable x will still have the value of 5. The value of x is not reset (or cleared) when you redeclare it. Javascript Arithmetic y=x-5; z=y+3;
  • 11. The + Operator Used on Strings txt1=&quot;What a very&quot;; txt2=&quot;nice day&quot;; txt3=txt1+txt2; Input Program: Output Program: What a very nice day Comparison Operators
  • 12. Logical Operators Syntax: variablename=(condition)?value1:value2  Example: greeting=(visitor==&quot;PRES&quot;)?&quot;Dear President &quot;:&quot;Dear &quot;; Result: “ Dear President” or else “Dear” Conditional Operators