SlideShare a Scribd company logo
JavaScript Introduction Aaron Conran Text: JavaScript The Definitive Guide By David Flannagan
Case Sensitive Example:  myVar  myVAr These are not the same variable.
(Optional) Semicolons JavaScript allows you to omit semicolons at the end of your statements. However this can create nasty bugs and cause difficult to debug problems. Use them at the end of statements and make your life easier.
Comments JavaScript supports both C and C++ style comments // this is a comment /* this is another comment */
Comments (JSDoc) Comments which begin with /** Note the 2 stars will be picked up by JSDoc JSDoc allows you to document your JavaScript classes in a formal manner similar to JavaDoc. Allows code and documentation to always be synchronized. For more information: http://jsdoc.sourceforge.net/
JavaScript Reserved Words Avoid the use of reserved words as variables and function names in your JavaScript.  For a full list Flanagan p19-20 Examples: break if switch in class
JavaScript DataTypes Numbers Strings Booleans Functions Objects Arrays null undefined Date Error
Numbers Integer (whole) Hexadecimal & Octal Floating-points (decimal) You can add, multiply divide and subtract numbers with their respective operator: +, *, /, & - The  Math  library of JavaScript also exposes a number of useful methods: Math.abs(num) Math.sin(num) Math.ceil(num) Full reference p 659-669
Special Numeric Values  (Table 3-1) p25 Special value to represent negative infinity Number.NEGATIVE_INFINITY Special value to represent infinity Number.POSTIVE_INFINITY Special not a number value Number.NaN Smallest (closest to zero) representable number Number.MIN_VALUE Largest representable number Number.MAX_VALUE Special not-a-number value NaN Special value to represent infinity Infinity Meaning Constant
Strings “ zero or more Unicode characters enclosed within single or double quotes” Examples: “” ‘ myForm’ “ testing” “ This is a longer string”
Escape Sequences To encode special values like new lines and ‘s in JavaScript strings you utilize a backslash Example: var menuText = ‘What\’s this?’;
Escape Sequences (Table 3-2) p27 The Latin-1 character specified by the octal digits XXX, between 1 and 377. Not support by ECMAScript v3; do not use this escpae sequence. \XXX The Unicode character specified by the four hexadecimal digits XXXX \uXXXX The Latin-1 character specified by the two hexadecimal digits XX \xXX Backslash (\u005C) \\ Apostrophe or single quote (u\0027) \’ Double quote (u\0022) \” Carriage return (u\000D) \r Form feed (\u000C) \f Vertical tab (\u000B) \v Newline (\u000A) \n Horizontal tab (\u0009) \t Backspace (\u0008) \b The NUL character (\u0000) \0 Character represented Sequence
Adding Strings You can also add (or concatenate) strings simply by adding them. Example: var anotherString = ‘new’; var newVariable = ‘Something ‘ + anotherString; When adding numbers they will automatically be converting to strings. Example: var x = 12; var newString = x + ‘ dozen eggs’;
Converting Strings To Numbers Utilize the parse Number  utility functions to extract numbers from strings. parseInt parseFloat Example: var x = “11”; var xNum = parseInt(x);
Booleans true (Other truthy values) 1 {} ‘ ‘  - space ‘ my String’ false (Other falsey values) undefined null 0 “” –  empty string
Equals vs Strictly Equals There is a strictly equals operator in JavaScript which will also check type as well as value. To show how this relates to boolean values: == Equals Works for Truthy values === Strictly Equals Works for truth only != Not Equals Works for Falsey values !== Strictly Not Equals Works for false only
Objects JavaScript Objects are similar to ColdFusion Structures. They consist of zero to many key-value pairs. They can be nested infinitely deep. They provide an associative array or hash map. Example: // using the Object constructor var newObj = new Object(); newObj.x = 10; newObj.y = 20; // OR using the Object literal syntax var newObj = {x: 10, y: 20};
Object Literal Object literal is the preferred way to create objects because it is concise and consistent with JSON-syntax. When utilizing object literal syntax key value pairs are separated by colon’s. Keys are called properties
Functions Functions are actually a datatype too Example: var myFn = function() {console.log(‘hi’);}; function myFn() {console.log(‘hi’);} These are 2 different ways of defining a similar function. There is also a Function constructor, however it’s use is limited because it can only create functions in the global scope.
Functions as Properties Properties of Objects can be any data type including Functions. Example: var myObject = {myFun: function() {console.log(‘hi’);}}; myObject.myFun();
Arrays Arrays can be defined using 2 syntaxes as well. Example: // Utilizing the Array constructor var myArray = new Array(); myArray[0] = 12; myArray[1] = 232; // OR using the Array literal syntax. var myArray = [12,232];
Arrays (cont.) Arrays can be infinitely nested Arrays can be sparse Arrays can store unlike datatypes Full reference available p 602-611 Arrays provide a number of useful properties and methods such as: length – property which defines how many elements are in the Array push – method which pushes another element on the Array when utilized as a Stack pop – method which pops an element off an Array when utilized as a Stack
null vs undefined null “ null  is a special keyword which indicates no value” undefined “ undefined  is returned when you use either a variable that has not been declared but never had a value assigned to it or an object property that does not exist”
null vs undefined Both of these equate to a  falsey  value. var myVar; // what is the value of myVar?

More Related Content

What's hot (20)

Real World Haskell: Lecture 6
Real World Haskell: Lecture 6Real World Haskell: Lecture 6
Real World Haskell: Lecture 6
Bryan O'Sullivan
 
Effective PHP. Part 1
Effective PHP. Part 1Effective PHP. Part 1
Effective PHP. Part 1
Vasily Kartashov
 
Effective PHP. Part 2
Effective PHP. Part 2Effective PHP. Part 2
Effective PHP. Part 2
Vasily Kartashov
 
Java script arrays
Java script arraysJava script arrays
Java script arrays
Frayosh Wadia
 
Strings in c language
Strings in  c languageStrings in  c language
Strings in c language
Infinity Tech Solutions
 
Effective PHP. Part 5
Effective PHP. Part 5Effective PHP. Part 5
Effective PHP. Part 5
Vasily Kartashov
 
Lesson 5
Lesson 5Lesson 5
Lesson 5
Vinnu Vinay
 
RFC4627 Reading
RFC4627 ReadingRFC4627 Reading
RFC4627 Reading
Yuuki Tan-nai
 
The JavaScript Programming Language
The JavaScript Programming LanguageThe JavaScript Programming Language
The JavaScript Programming Language
Mohammed Irfan Shaikh
 
Effective PHP. Part 3
Effective PHP. Part 3Effective PHP. Part 3
Effective PHP. Part 3
Vasily Kartashov
 
Cross platform native development in f#
Cross platform native development in f#Cross platform native development in f#
Cross platform native development in f#
David Kay
 
Text processing by Rj
Text processing by RjText processing by Rj
Text processing by Rj
Shree M.L.Kakadiya MCA mahila college, Amreli
 
Scala Paradigms
Scala ParadigmsScala Paradigms
Scala Paradigms
Tom Flaherty
 
Complete Notes on Angular 2 and TypeScript
Complete Notes on Angular 2 and TypeScriptComplete Notes on Angular 2 and TypeScript
Complete Notes on Angular 2 and TypeScript
EPAM Systems
 
Real World Haskell: Lecture 2
Real World Haskell: Lecture 2Real World Haskell: Lecture 2
Real World Haskell: Lecture 2
Bryan O'Sullivan
 
function, storage class and array and strings
 function, storage class and array and strings function, storage class and array and strings
function, storage class and array and strings
Rai University
 
Data types in php
Data types in phpData types in php
Data types in php
ilakkiya
 
Suit case class
Suit case classSuit case class
Suit case class
Didier Plaindoux
 
C# programming
C# programming C# programming
C# programming
umesh patil
 
Mcai pic u 4 function, storage class and array and strings
Mcai pic u 4 function, storage class and array and stringsMcai pic u 4 function, storage class and array and strings
Mcai pic u 4 function, storage class and array and strings
Rai University
 

Viewers also liked (8)

Introduction to javascript
Introduction to javascriptIntroduction to javascript
Introduction to javascript
Syd Lawrence
 
Intro to JavaScript
Intro to JavaScriptIntro to JavaScript
Intro to JavaScript
Dan Phiffer
 
8 introduction to_java_script
8 introduction to_java_script8 introduction to_java_script
8 introduction to_java_script
Vijay Kalyan
 
Java script
Java scriptJava script
Java script
Shyam Khant
 
Java script
Java scriptJava script
Java script
Fajar Baskoro
 
Session 3 Java Script
Session 3 Java ScriptSession 3 Java Script
Session 3 Java Script
Muhammad Hesham
 
What is Big Data?
What is Big Data?What is Big Data?
What is Big Data?
Bernard Marr
 
Big data ppt
Big  data pptBig  data ppt
Big data ppt
Nasrin Hussain
 
Ad

Similar to Java Script Introduction (20)

An introduction to javascript
An introduction to javascriptAn introduction to javascript
An introduction to javascript
MD Sayem Ahmed
 
Front end fundamentals session 1: javascript core
Front end fundamentals session 1: javascript coreFront end fundamentals session 1: javascript core
Front end fundamentals session 1: javascript core
Web Zhao
 
JavaScript.pptx
JavaScript.pptxJavaScript.pptx
JavaScript.pptx
KennyPratheepKumar
 
03. Week 03.pptx
03. Week 03.pptx03. Week 03.pptx
03. Week 03.pptx
Vinc2ntCabrera
 
javascript objects
javascript objectsjavascript objects
javascript objects
Vijay Kalyan
 
Js ch-1
Js ch-1Js ch-1
Js ch-1
Saritapol13
 
Chapter 1 .pptx
Chapter 1 .pptxChapter 1 .pptx
Chapter 1 .pptx
MohamedAbdullahiYusu
 
Introduction to Client-Side Javascript
Introduction to Client-Side JavascriptIntroduction to Client-Side Javascript
Introduction to Client-Side Javascript
Julie Iskander
 
js_class_notes_for_ institute it is very useful for your study.pdf
js_class_notes_for_ institute  it is very useful for your study.pdfjs_class_notes_for_ institute  it is very useful for your study.pdf
js_class_notes_for_ institute it is very useful for your study.pdf
Well82
 
Chapter 2: What's your type?
Chapter 2: What's your type?Chapter 2: What's your type?
Chapter 2: What's your type?
Seth McLaughlin
 
A Re-Introduction to JavaScript
A Re-Introduction to JavaScriptA Re-Introduction to JavaScript
A Re-Introduction to JavaScript
Simon Willison
 
GeoGebra JavaScript CheatSheet
GeoGebra JavaScript CheatSheetGeoGebra JavaScript CheatSheet
GeoGebra JavaScript CheatSheet
Jose Perez
 
Javascript
JavascriptJavascript
Javascript
vikram singh
 
JavaScript introduction 1 ( Variables And Values )
JavaScript introduction 1 ( Variables And Values )JavaScript introduction 1 ( Variables And Values )
JavaScript introduction 1 ( Variables And Values )
Victor Verhaagen
 
JavaScript Proven Practises
JavaScript Proven PractisesJavaScript Proven Practises
JavaScript Proven Practises
Robert MacLean
 
Java script basics
Java script basicsJava script basics
Java script basics
Shrivardhan Limbkar
 
Fewd week5 slides
Fewd week5 slidesFewd week5 slides
Fewd week5 slides
William Myers
 
JavaScript blast
JavaScript blastJavaScript blast
JavaScript blast
dominion
 
Handout - Introduction to Programming
Handout - Introduction to ProgrammingHandout - Introduction to Programming
Handout - Introduction to Programming
Cindy Royal
 
Javascript variables and datatypes
Javascript variables and datatypesJavascript variables and datatypes
Javascript variables and datatypes
Varun C M
 
An introduction to javascript
An introduction to javascriptAn introduction to javascript
An introduction to javascript
MD Sayem Ahmed
 
Front end fundamentals session 1: javascript core
Front end fundamentals session 1: javascript coreFront end fundamentals session 1: javascript core
Front end fundamentals session 1: javascript core
Web Zhao
 
javascript objects
javascript objectsjavascript objects
javascript objects
Vijay Kalyan
 
Introduction to Client-Side Javascript
Introduction to Client-Side JavascriptIntroduction to Client-Side Javascript
Introduction to Client-Side Javascript
Julie Iskander
 
js_class_notes_for_ institute it is very useful for your study.pdf
js_class_notes_for_ institute  it is very useful for your study.pdfjs_class_notes_for_ institute  it is very useful for your study.pdf
js_class_notes_for_ institute it is very useful for your study.pdf
Well82
 
Chapter 2: What's your type?
Chapter 2: What's your type?Chapter 2: What's your type?
Chapter 2: What's your type?
Seth McLaughlin
 
A Re-Introduction to JavaScript
A Re-Introduction to JavaScriptA Re-Introduction to JavaScript
A Re-Introduction to JavaScript
Simon Willison
 
GeoGebra JavaScript CheatSheet
GeoGebra JavaScript CheatSheetGeoGebra JavaScript CheatSheet
GeoGebra JavaScript CheatSheet
Jose Perez
 
JavaScript introduction 1 ( Variables And Values )
JavaScript introduction 1 ( Variables And Values )JavaScript introduction 1 ( Variables And Values )
JavaScript introduction 1 ( Variables And Values )
Victor Verhaagen
 
JavaScript Proven Practises
JavaScript Proven PractisesJavaScript Proven Practises
JavaScript Proven Practises
Robert MacLean
 
JavaScript blast
JavaScript blastJavaScript blast
JavaScript blast
dominion
 
Handout - Introduction to Programming
Handout - Introduction to ProgrammingHandout - Introduction to Programming
Handout - Introduction to Programming
Cindy Royal
 
Javascript variables and datatypes
Javascript variables and datatypesJavascript variables and datatypes
Javascript variables and datatypes
Varun C M
 
Ad

More from jason hu 金良胡 (20)

Windows Powershell En
Windows Powershell   EnWindows Powershell   En
Windows Powershell En
jason hu 金良胡
 
Ubunturef
UbunturefUbunturef
Ubunturef
jason hu 金良胡
 
Asp.Net运行时
Asp.Net运行时Asp.Net运行时
Asp.Net运行时
jason hu 金良胡
 
X Query
X QueryX Query
X Query
jason hu 金良胡
 
Sql2005 Xml
Sql2005 XmlSql2005 Xml
Sql2005 Xml
jason hu 金良胡
 
Ms Ajax Dom Element Class
Ms Ajax Dom Element ClassMs Ajax Dom Element Class
Ms Ajax Dom Element Class
jason hu 金良胡
 
Ms Ajax Dom Element Class
Ms Ajax Dom Element ClassMs Ajax Dom Element Class
Ms Ajax Dom Element Class
jason hu 金良胡
 
Ms Ajax Number And Error Extensions
Ms Ajax Number And Error ExtensionsMs Ajax Number And Error Extensions
Ms Ajax Number And Error Extensions
jason hu 金良胡
 
Ms Ajax Dom Event Class
Ms Ajax Dom Event ClassMs Ajax Dom Event Class
Ms Ajax Dom Event Class
jason hu 金良胡
 
Ms Ajax Date And Boolean Extensions
Ms Ajax Date And Boolean ExtensionsMs Ajax Date And Boolean Extensions
Ms Ajax Date And Boolean Extensions
jason hu 金良胡
 
Ms Ajax Array Extensions
Ms Ajax Array ExtensionsMs Ajax Array Extensions
Ms Ajax Array Extensions
jason hu 金良胡
 
Ext Js Events
Ext Js EventsExt Js Events
Ext Js Events
jason hu 金良胡
 
Ext Js Dom Navigation
Ext Js Dom NavigationExt Js Dom Navigation
Ext Js Dom Navigation
jason hu 金良胡
 
Ext Js Events
Ext Js EventsExt Js Events
Ext Js Events
jason hu 金良胡
 

Recently uploaded (20)

Enabling BIM / GIS integrations with Other Systems with FME
Enabling BIM / GIS integrations with Other Systems with FMEEnabling BIM / GIS integrations with Other Systems with FME
Enabling BIM / GIS integrations with Other Systems with FME
Safe Software
 
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Anish Kumar
 
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Safe Software
 
Edge-banding-machines-edgeteq-s-200-en-.pdf
Edge-banding-machines-edgeteq-s-200-en-.pdfEdge-banding-machines-edgeteq-s-200-en-.pdf
Edge-banding-machines-edgeteq-s-200-en-.pdf
AmirStern2
 
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdfHow Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
Rejig Digital
 
Domino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
Domino IQ – Was Sie erwartet, erste Schritte und AnwendungsfälleDomino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
Domino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
panagenda
 
If You Use Databricks, You Definitely Need FME
If You Use Databricks, You Definitely Need FMEIf You Use Databricks, You Definitely Need FME
If You Use Databricks, You Definitely Need FME
Safe Software
 
Crypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdfCrypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdf
Stephen Perrenod
 
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdfcnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
AmirStern2
 
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Impelsys Inc.
 
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely
 
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free DownloadViral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Puppy jhon
 
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven InfrastructureNo-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
Safe Software
 
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc Webinar - 2025 Global Privacy SurveyTrustArc Webinar - 2025 Global Privacy Survey
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc
 
Oracle Cloud Infrastructure Generative AI Professional
Oracle Cloud Infrastructure Generative AI ProfessionalOracle Cloud Infrastructure Generative AI Professional
Oracle Cloud Infrastructure Generative AI Professional
VICTOR MAESTRE RAMIREZ
 
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
vertical-cnc-processing-centers-drillteq-v-200-en.pdfvertical-cnc-processing-centers-drillteq-v-200-en.pdf
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
AmirStern2
 
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Shashikant Jagtap
 
Introduction to Internet of things .ppt.
Introduction to Internet of things .ppt.Introduction to Internet of things .ppt.
Introduction to Internet of things .ppt.
hok12341073
 
Secure Access with Azure Active Directory
Secure Access with Azure Active DirectorySecure Access with Azure Active Directory
Secure Access with Azure Active Directory
VICTOR MAESTRE RAMIREZ
 
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
angelo60207
 
Enabling BIM / GIS integrations with Other Systems with FME
Enabling BIM / GIS integrations with Other Systems with FMEEnabling BIM / GIS integrations with Other Systems with FME
Enabling BIM / GIS integrations with Other Systems with FME
Safe Software
 
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Anish Kumar
 
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Safe Software
 
Edge-banding-machines-edgeteq-s-200-en-.pdf
Edge-banding-machines-edgeteq-s-200-en-.pdfEdge-banding-machines-edgeteq-s-200-en-.pdf
Edge-banding-machines-edgeteq-s-200-en-.pdf
AmirStern2
 
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdfHow Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
Rejig Digital
 
Domino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
Domino IQ – Was Sie erwartet, erste Schritte und AnwendungsfälleDomino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
Domino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
panagenda
 
If You Use Databricks, You Definitely Need FME
If You Use Databricks, You Definitely Need FMEIf You Use Databricks, You Definitely Need FME
If You Use Databricks, You Definitely Need FME
Safe Software
 
Crypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdfCrypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdf
Stephen Perrenod
 
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdfcnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
AmirStern2
 
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Impelsys Inc.
 
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely
 
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free DownloadViral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Puppy jhon
 
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven InfrastructureNo-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
Safe Software
 
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc Webinar - 2025 Global Privacy SurveyTrustArc Webinar - 2025 Global Privacy Survey
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc
 
Oracle Cloud Infrastructure Generative AI Professional
Oracle Cloud Infrastructure Generative AI ProfessionalOracle Cloud Infrastructure Generative AI Professional
Oracle Cloud Infrastructure Generative AI Professional
VICTOR MAESTRE RAMIREZ
 
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
vertical-cnc-processing-centers-drillteq-v-200-en.pdfvertical-cnc-processing-centers-drillteq-v-200-en.pdf
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
AmirStern2
 
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Shashikant Jagtap
 
Introduction to Internet of things .ppt.
Introduction to Internet of things .ppt.Introduction to Internet of things .ppt.
Introduction to Internet of things .ppt.
hok12341073
 
Secure Access with Azure Active Directory
Secure Access with Azure Active DirectorySecure Access with Azure Active Directory
Secure Access with Azure Active Directory
VICTOR MAESTRE RAMIREZ
 
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
angelo60207
 

Java Script Introduction

  • 1. JavaScript Introduction Aaron Conran Text: JavaScript The Definitive Guide By David Flannagan
  • 2. Case Sensitive Example: myVar myVAr These are not the same variable.
  • 3. (Optional) Semicolons JavaScript allows you to omit semicolons at the end of your statements. However this can create nasty bugs and cause difficult to debug problems. Use them at the end of statements and make your life easier.
  • 4. Comments JavaScript supports both C and C++ style comments // this is a comment /* this is another comment */
  • 5. Comments (JSDoc) Comments which begin with /** Note the 2 stars will be picked up by JSDoc JSDoc allows you to document your JavaScript classes in a formal manner similar to JavaDoc. Allows code and documentation to always be synchronized. For more information: http://jsdoc.sourceforge.net/
  • 6. JavaScript Reserved Words Avoid the use of reserved words as variables and function names in your JavaScript. For a full list Flanagan p19-20 Examples: break if switch in class
  • 7. JavaScript DataTypes Numbers Strings Booleans Functions Objects Arrays null undefined Date Error
  • 8. Numbers Integer (whole) Hexadecimal & Octal Floating-points (decimal) You can add, multiply divide and subtract numbers with their respective operator: +, *, /, & - The Math library of JavaScript also exposes a number of useful methods: Math.abs(num) Math.sin(num) Math.ceil(num) Full reference p 659-669
  • 9. Special Numeric Values (Table 3-1) p25 Special value to represent negative infinity Number.NEGATIVE_INFINITY Special value to represent infinity Number.POSTIVE_INFINITY Special not a number value Number.NaN Smallest (closest to zero) representable number Number.MIN_VALUE Largest representable number Number.MAX_VALUE Special not-a-number value NaN Special value to represent infinity Infinity Meaning Constant
  • 10. Strings “ zero or more Unicode characters enclosed within single or double quotes” Examples: “” ‘ myForm’ “ testing” “ This is a longer string”
  • 11. Escape Sequences To encode special values like new lines and ‘s in JavaScript strings you utilize a backslash Example: var menuText = ‘What\’s this?’;
  • 12. Escape Sequences (Table 3-2) p27 The Latin-1 character specified by the octal digits XXX, between 1 and 377. Not support by ECMAScript v3; do not use this escpae sequence. \XXX The Unicode character specified by the four hexadecimal digits XXXX \uXXXX The Latin-1 character specified by the two hexadecimal digits XX \xXX Backslash (\u005C) \\ Apostrophe or single quote (u\0027) \’ Double quote (u\0022) \” Carriage return (u\000D) \r Form feed (\u000C) \f Vertical tab (\u000B) \v Newline (\u000A) \n Horizontal tab (\u0009) \t Backspace (\u0008) \b The NUL character (\u0000) \0 Character represented Sequence
  • 13. Adding Strings You can also add (or concatenate) strings simply by adding them. Example: var anotherString = ‘new’; var newVariable = ‘Something ‘ + anotherString; When adding numbers they will automatically be converting to strings. Example: var x = 12; var newString = x + ‘ dozen eggs’;
  • 14. Converting Strings To Numbers Utilize the parse Number utility functions to extract numbers from strings. parseInt parseFloat Example: var x = “11”; var xNum = parseInt(x);
  • 15. Booleans true (Other truthy values) 1 {} ‘ ‘ - space ‘ my String’ false (Other falsey values) undefined null 0 “” – empty string
  • 16. Equals vs Strictly Equals There is a strictly equals operator in JavaScript which will also check type as well as value. To show how this relates to boolean values: == Equals Works for Truthy values === Strictly Equals Works for truth only != Not Equals Works for Falsey values !== Strictly Not Equals Works for false only
  • 17. Objects JavaScript Objects are similar to ColdFusion Structures. They consist of zero to many key-value pairs. They can be nested infinitely deep. They provide an associative array or hash map. Example: // using the Object constructor var newObj = new Object(); newObj.x = 10; newObj.y = 20; // OR using the Object literal syntax var newObj = {x: 10, y: 20};
  • 18. Object Literal Object literal is the preferred way to create objects because it is concise and consistent with JSON-syntax. When utilizing object literal syntax key value pairs are separated by colon’s. Keys are called properties
  • 19. Functions Functions are actually a datatype too Example: var myFn = function() {console.log(‘hi’);}; function myFn() {console.log(‘hi’);} These are 2 different ways of defining a similar function. There is also a Function constructor, however it’s use is limited because it can only create functions in the global scope.
  • 20. Functions as Properties Properties of Objects can be any data type including Functions. Example: var myObject = {myFun: function() {console.log(‘hi’);}}; myObject.myFun();
  • 21. Arrays Arrays can be defined using 2 syntaxes as well. Example: // Utilizing the Array constructor var myArray = new Array(); myArray[0] = 12; myArray[1] = 232; // OR using the Array literal syntax. var myArray = [12,232];
  • 22. Arrays (cont.) Arrays can be infinitely nested Arrays can be sparse Arrays can store unlike datatypes Full reference available p 602-611 Arrays provide a number of useful properties and methods such as: length – property which defines how many elements are in the Array push – method which pushes another element on the Array when utilized as a Stack pop – method which pops an element off an Array when utilized as a Stack
  • 23. null vs undefined null “ null is a special keyword which indicates no value” undefined “ undefined is returned when you use either a variable that has not been declared but never had a value assigned to it or an object property that does not exist”
  • 24. null vs undefined Both of these equate to a falsey value. var myVar; // what is the value of myVar?