SlideShare una empresa de 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

Más contenido relacionado

La actualidad más candente

Java script
Java scriptJava script
Java scriptITz_1
 
Basics of Javascript
Basics of Javascript Basics of Javascript
Basics of Javascript poojanov04
 
Razor new view engine asp.net
Razor new view engine asp.netRazor new view engine asp.net
Razor new view engine asp.netahsanmm
 
Scripting languages
Scripting languagesScripting languages
Scripting languagesteach4uin
 
JavaScript Introduction
JavaScript IntroductionJavaScript Introduction
JavaScript IntroductionJainul Musani
 
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 javascriptCK Yang
 
Introduction to javaScript
Introduction to javaScriptIntroduction to javaScript
Introduction to javaScriptNeil Ghosh
 
Coder Presentation
Coder  PresentationCoder  Presentation
Coder PresentationDoug Green
 

La actualidad más candente (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
 

Destacado

ศิลปะฉับพลัน54
ศิลปะฉับพลัน54ศิลปะฉับพลัน54
ศิลปะฉับพลัน54sdsdsds
 
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 guiAndy de Vera
 
Javascript survival2
Javascript survival2Javascript survival2
Javascript survival2Andy de Vera
 
กลุ่ม54 ศิลปะฉับพลัน
กลุ่ม54  ศิลปะฉับพลันกลุ่ม54  ศิลปะฉับพลัน
กลุ่ม54 ศิลปะฉับพลันsdsdsds
 

Destacado (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 ศิลปะฉับพลัน
 

Similar a Javascript survival for CSBN Sophomores

Similar 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

microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
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 ClassesCeline George
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxcallscotland1987
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Association for Project Management
 
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.pptxDenish Jangid
 
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.pptxnegromaestrong
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
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Ữ Â...Nguyen Thanh Tu Collection
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
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...pradhanghanshyam7136
 
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).pptxdhanalakshmis0310
 
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 PractiseAnaAcapella
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 

Último (20)

microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
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
 
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
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
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
 
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
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
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Ữ Â...
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
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...
 
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
 
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
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.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