SlideShare a Scribd company logo
JavaScript for ABAP Programmers
Data Types
Chris Whealy / The RIG
ABAP
Strongly typed
Syntax similar to COBOL
Block Scope
No equivalent concept
OO using class based inheritance
Imperative programming

JavaScript
Weakly typed
Syntax derived from Java
Lexical Scope
Functions are 1st class citizens
OO using referential inheritance
Imperative or Functional programming
Strongly Typed vs. Weakly Typed Languages
There are two schools of thought for determining how data should be stored in variables:
• ABAP uses Strong (or Static) Typing
Apart from field symbols, all ABAP variables
must have their data type defined at declaration
time

© 2013 SAP AG. All rights reserved.

3
Strongly Typed vs. Weakly Typed Languages
There are two schools of thought for determining how data should be stored in variables:
• ABAP uses Strong (or Static) Typing
• JavaScript uses Weak (or Dynamic) Typing
Apart from field symbols, all ABAP variables
A variable takes on the data type of whatever
must have their data type defined at declaration
value it currently holds
time

© 2013 SAP AG. All rights reserved.

4
Strongly Typed vs. Weakly Typed Languages
There are two schools of thought for determining how data should be stored in variables:
• ABAP uses Strong (or Static) Typing
• JavaScript uses Weak (or Dynamic) Typing
Apart from field symbols, all ABAP variables
A variable takes on the data type of whatever
must have their data type defined at declaration
value it currently holds
time
• Pros and Cons of Strong Typing

+ Data type errors can be trapped at compile time
- Rigid type systems reduce language flexibility

© 2013 SAP AG. All rights reserved.

5
Strongly Typed vs. Weakly Typed Languages
There are two schools of thought for determining how data should be stored in variables:
• ABAP uses Strong (or Static) Typing
• JavaScript uses Weak (or Dynamic) Typing
Apart from field symbols, all ABAP variables
A variable takes on the data type of whatever
must have their data type defined at declaration
value it currently holds
time
• Pros and Cons of Strong Typing
• Pros and Cons of Weak Typing

+ Data type errors can be trapped at compile time
- Rigid type systems reduce language flexibility

- Data type errors can only be trapped at runtime
+ Highly flexible type system allows for a dynamic
style of coding

© 2013 SAP AG. All rights reserved.

6
Strongly Typed vs. Weakly Typed Languages
There are two schools of thought for determining how data should be stored in variables:
• ABAP uses Strong (or Static) Typing
• JavaScript uses Weak (or Dynamic) Typing
Apart from field symbols, all ABAP variables
A variable takes on the data type of whatever
must have their data type defined at declaration
value it currently holds
time
• Pros and Cons of Strong Typing
• Pros and Cons of Weak Typing

+ Data type errors can be trapped at compile time
- Rigid type systems reduce language flexibility

- Data type errors can only be trapped at runtime
+ Highly flexible type system allows for a dynamic
style of coding

Compiled languages (E.G. ABAP, Java, C) tend to use strong typing, whereas interpreted scripting
languages (E.G. JavaScript, Ruby, Python) tend to use weak typing.

© 2013 SAP AG. All rights reserved.

7
JavaScript Data Types: Overview
In JavaScript, there are only 6 data types.
At any one time the value of a variable belongs to one and only one of the following data types.

Data Type

This value of this variable…

Null

Is explicitly defined as having no value

Undefined

Is indeterminate

Boolean

Is either true or false

String

Is an immutable collection of zero or more Unicode characters

Number

Can be used in mathematical operations

Object

Is an unordered collection of name/value pairs

© 2013 SAP AG. All rights reserved.

8
JavaScript Data Types 1/3
In the coding, the data types are specified as follows:
// -----------------------------------------------------------------------------------------------// Special
null;
// Indicates an explicit non-value
undefined;
// Indicates an indeterminate value (E.G. a variable is declared but not initialised)

© 2013 SAP AG. All rights reserved.

9
JavaScript Data Types 1/3
In the coding, the data types are specified as follows:
// -----------------------------------------------------------------------------------------------// Special
null;
// Indicates an explicit non-value
undefined;
// Indicates an indeterminate value (E.G. a variable is declared but not initialised)
// -----------------------------------------------------------------------------------------------// Boolean
true;
false;

© 2013 SAP AG. All rights reserved.

10
JavaScript Data Types 1/3
In the coding, the data types are specified as follows:
// -----------------------------------------------------------------------------------------------// Special
null;
// Indicates an explicit non-value
undefined;
// Indicates an indeterminate value (E.G. a variable is declared but not initialised)
// -----------------------------------------------------------------------------------------------// Boolean
true;
false;
// -----------------------------------------------------------------------------------------------// String – contains zero or more Unicode characters
'Bazinga!';
// Can be delimited by either single quotes
"";
// Or double quotes

© 2013 SAP AG. All rights reserved.

11
JavaScript Data Types 2/3
In the coding, the data types are specified as follows:
// -----------------------------------------------------------------------------------------------// Number
3.1415926;
// Stored as 64-bit floating point number
1;
// Be careful, this is stored as floating point value, not an integer!

© 2013 SAP AG. All rights reserved.

12
JavaScript Data Types 2/3
In the coding, the data types are specified as follows:
// -----------------------------------------------------------------------------------------------// Number
3.1415926;
// Stored as 64-bit floating point number
1;
// Be careful, this is stored as floating point value, not an integer!
// Warning! All the usual problems associated with trying to represent decimal values in binary
// floating point format still apply in JavaScript!
var result = 0.1 + 0.2;
result;
//  0.30000000000000004, not 0.3 (Decimal 0.1 has no exact binary equivalent)

© 2013 SAP AG. All rights reserved.

13
JavaScript Data Types 2/3
In the coding, the data types are specified as follows:
// -----------------------------------------------------------------------------------------------// Number
3.1415926;
// Stored as 64-bit floating point number
1;
// Be careful, this is stored as floating point value, not an integer!
// Warning! All the usual problems associated with trying to represent decimal values in binary
// floating point format still apply in JavaScript!
var result = 0.1 + 0.2;
result;
//  0.30000000000000004, not 0.3 (Decimal 0.1 has no exact binary equivalent)
// Special numerical values that could be returned in the event of illegal mathematical operations
// (These values are actually stored as properties of the Global Object)
NaN;
// 'Not a Number' E.G. 1/'cat'  NaN
Infinity;
// The result of division by zero

© 2013 SAP AG. All rights reserved.

14
JavaScript Data Types 3/3
In addition to the basic data type of Object, JavaScript provides several built-in objects that behave as
if they were composite data types. E.G. Array, Date, Function, Math and RegEx etc.
// -----------------------------------------------------------------------------------------------// Object. Zero or more unordered name:value pairs of any data type delimited by curly braces
{ pet1: 'cat',
pet2: 'dog' };

© 2013 SAP AG. All rights reserved.

15
JavaScript Data Types 3/3
In addition to the basic data type of Object, JavaScript provides several built-in objects that behave as
if they were composite data types. E.G. Array, Date, Function, Math and RegEx etc.
// -----------------------------------------------------------------------------------------------// Object. Zero or more unordered name:value pairs of any data type delimited by curly braces
{ pet1: 'cat',
pet2: 'dog' };
// Array object. Zero or more values of any data type accessed by a numerical, 0 based index
[1,2,3,4,5];

© 2013 SAP AG. All rights reserved.

16
JavaScript Data Types 3/3
In addition to the basic data type of Object, JavaScript provides several built-in objects that behave as
if they were composite data types. E.G. Array, Date, Function, Math and RegEx etc.
// -----------------------------------------------------------------------------------------------// Object. Zero or more unordered name:value pairs of any data type delimited by curly braces
{ pet1: 'cat',
pet2: 'dog' };
// Array object. Zero or more values of any data type accessed by a numerical, 0 based index
[1,2,3,4,5];
// Function object. A special object that has both properties and executable content
function() { /* statements */ }

© 2013 SAP AG. All rights reserved.

17
JavaScript Data Types 3/3
In addition to the basic data type of Object, JavaScript provides several built-in objects that behave as
if they were composite data types. E.G. Array, Date, Function, Math and RegEx etc.
// -----------------------------------------------------------------------------------------------// Object. Zero or more unordered name:value pairs of any data type delimited by curly braces
{ pet1: 'cat',
pet2: 'dog' };
// Array object. Zero or more values of any data type accessed by a numerical, 0 based index
[1,2,3,4,5];
// Function object. A special object that has both properties and executable content
function() { /* statements */ }
// Math object. Contains many useful mathematical functions and constants
Math.PI; //  3.141592653589793

© 2013 SAP AG. All rights reserved.

18
JavaScript Data Types 3/3
In addition to the basic data type of Object, JavaScript provides several built-in objects that behave as
if they were composite data types. E.G. Array, Date, Function, Math and RegEx etc.
// -----------------------------------------------------------------------------------------------// Object. Zero or more unordered name:value pairs of any data type delimited by curly braces
{ pet1: 'cat',
pet2: 'dog' };
// Array object. Zero or more values of any data type accessed by a numerical, 0 based index
[1,2,3,4,5];
// Function object. A special object that has both properties and executable content
function() { /* statements */ }
// Math object. Contains many useful mathematical functions and constants
Math.PI; //  3.141592653589793
// Regular Expression Object. A tool for specifying and extracting patterns of text within a string
/^(?:([A-Za-z]+):)?(/{0,3})([0-9.-A-Za-z]+)(?::(d+))?(?:/([^?#]*))?(?:?([^#]*))?(?:#(.*))?$/;

© 2013 SAP AG. All rights reserved.

19
JavaScript Data Types 3/3
In addition to the basic data type of Object, JavaScript provides several built-in objects that behave as
if they were composite data types. E.G. Array, Date, Function, Math and RegEx etc.
// -----------------------------------------------------------------------------------------------// Object. Zero or more unordered name:value pairs of any data type delimited by curly braces
{ pet1: 'cat',
pet2: 'dog' };
// Array object. Zero or more values of any data type accessed by a numerical, 0 based index
[1,2,3,4,5];
// Function object. A special object that has both properties and executable content
function() { /* statements */ }
// Math object. Contains many useful mathematical functions and constants
Math.PI; //  3.141592653589793
// Regular Expression Object. A tool for specifying and extracting patterns of text within a string
// Regular expressions are sometimes confused with Egyptian hieroglyphics... :-)

© 2013 SAP AG. All rights reserved.

20
Variables and Data Types
In weakly typed languages such as JavaScript, there is no concept of declaring that a variable should hold data of
a particular type. The data type of a variable is determined simply by the value it currently holds.
// A weakly typed language means that data types are determined
// dynamically at runtime, not statically at design time
var whoAmI = 'Hello world';

© 2013 SAP AG. All rights reserved.

// Variable 'whoAmI' is both declared & assigned a string value

21
Variables and Data Types
In weakly typed languages such as JavaScript, there is no concept of declaring that a variable should hold data of
a particular type. The data type of a variable is determined simply by the value it currently holds.
// A weakly typed language means that data types are determined
// dynamically at runtime, not statically at design time
var whoAmI = 'Hello world';

// Variable 'whoAmI' is both declared & assigned a string value

whoAmI = 1.61792;
whoAmI = [1,2,3,4,5];

// Now it's a number
// Now it's an array

© 2013 SAP AG. All rights reserved.

22
Variables and Data Types
In weakly typed languages such as JavaScript, there is no concept of declaring that a variable should hold data of
a particular type. The data type of a variable is determined simply by the value it currently holds.
// A weakly typed language means that data types are determined
// dynamically at runtime, not statically at design time
var whoAmI = 'Hello world';

// Variable 'whoAmI' is both declared & assigned a string value

whoAmI = 1.61792;
whoAmI = [1,2,3,4,5];

// Now it's a number
// Now it's an array

whoAmI = true;

// Now it's a Boolean

© 2013 SAP AG. All rights reserved.

23
Variables and Data Types
In weakly typed languages such as JavaScript, there is no concept of declaring that a variable should hold data of
a particular type. The data type of a variable is determined simply by the value it currently holds.
// A weakly typed language means that data types are determined
// dynamically at runtime, not statically at design time
var whoAmI = 'Hello world';

// Variable 'whoAmI' is both declared & assigned a string value

whoAmI = 1.61792;
whoAmI = [1,2,3,4,5];

// Now it's a number
// Now it's an array

whoAmI = true;

// Now it's a Boolean

whoAmI = {
// Now it's an object
someProperty: 'Hello world'
}

© 2013 SAP AG. All rights reserved.

24
Variables and Data Types
In weakly typed languages such as JavaScript, there is no concept of declaring that a variable should hold data of
a particular type. The data type of a variable is determined simply by the value it currently holds.
// A weakly typed language means that data types are determined
// dynamically at runtime, not statically at design time
var whoAmI = 'Hello world';

// Variable 'whoAmI' is both declared & assigned a string value

whoAmI = 1.61792;
whoAmI = [1,2,3,4,5];

// Now it's a number
// Now it's an array

whoAmI = true;

// Now it's a Boolean

whoAmI = {
// Now it's an object
someProperty: 'Hello world'
}
whoAmI = function() { };

© 2013 SAP AG. All rights reserved.

// Now it's a...you get the idea

25

More Related Content

What's hot (20)

History of JavaScript
History of JavaScript
Rajat Saxena
 
Extending Flink SQL for stream processing use cases
Extending Flink SQL for stream processing use cases
Flink Forward
 
Helpful logging with python
Helpful logging with python
roskakori
 
(알도개) GraalVM – 자바를 넘어선 새로운 시작의 서막
(알도개) GraalVM – 자바를 넘어선 새로운 시작의 서막
Jay Park
 
CNCF and Cloud Native Intro
CNCF and Cloud Native Intro
Cloud Native Bangalore
 
Learn C# Programming - Decision Making & Loops
Learn C# Programming - Decision Making & Loops
Eng Teong Cheah
 
Get Started with ReactJS 18 Development Services_ New Features and Updates.pptx
Get Started with ReactJS 18 Development Services_ New Features and Updates.pptx
Concetto Labs
 
Fast Data with Apache Ignite and Apache Spark with Christos Erotocritou
Fast Data with Apache Ignite and Apache Spark with Christos Erotocritou
Spark Summit
 
Choisir entre une API RPC, SOAP, REST, GraphQL? 
Et si le problème était ai...
Choisir entre une API RPC, SOAP, REST, GraphQL? 
Et si le problème était ai...
François-Guillaume Ribreau
 
Intro to Erlang
Intro to Erlang
Ken Pratt
 
Discover Quarkus and GraalVM
Discover Quarkus and GraalVM
Romain Schlick
 
Tuning Speculative Retries to Fight Latency (Michael Figuiere, Minh Do, Netfl...
Tuning Speculative Retries to Fight Latency (Michael Figuiere, Minh Do, Netfl...
DataStax
 
Unified Stream and Batch Processing with Apache Flink
Unified Stream and Batch Processing with Apache Flink
DataWorks Summit/Hadoop Summit
 
C++
C++
Shyam Khant
 
Kafka slideshare
Kafka slideshare
wonyong hwang
 
Machine Learning using Kubeflow and Kubernetes
Machine Learning using Kubeflow and Kubernetes
Arun Gupta
 
Java Performance Analysis on Linux with Flame Graphs
Java Performance Analysis on Linux with Flame Graphs
Brendan Gregg
 
Linux BPF Superpowers
Linux BPF Superpowers
Brendan Gregg
 
Resilience4j with Spring Boot
Resilience4j with Spring Boot
Knoldus Inc.
 
Cloud Native Java GraalVM 이상과 현실
Cloud Native Java GraalVM 이상과 현실
Taewan Kim
 
History of JavaScript
History of JavaScript
Rajat Saxena
 
Extending Flink SQL for stream processing use cases
Extending Flink SQL for stream processing use cases
Flink Forward
 
Helpful logging with python
Helpful logging with python
roskakori
 
(알도개) GraalVM – 자바를 넘어선 새로운 시작의 서막
(알도개) GraalVM – 자바를 넘어선 새로운 시작의 서막
Jay Park
 
Learn C# Programming - Decision Making & Loops
Learn C# Programming - Decision Making & Loops
Eng Teong Cheah
 
Get Started with ReactJS 18 Development Services_ New Features and Updates.pptx
Get Started with ReactJS 18 Development Services_ New Features and Updates.pptx
Concetto Labs
 
Fast Data with Apache Ignite and Apache Spark with Christos Erotocritou
Fast Data with Apache Ignite and Apache Spark with Christos Erotocritou
Spark Summit
 
Choisir entre une API RPC, SOAP, REST, GraphQL? 
Et si le problème était ai...
Choisir entre une API RPC, SOAP, REST, GraphQL? 
Et si le problème était ai...
François-Guillaume Ribreau
 
Intro to Erlang
Intro to Erlang
Ken Pratt
 
Discover Quarkus and GraalVM
Discover Quarkus and GraalVM
Romain Schlick
 
Tuning Speculative Retries to Fight Latency (Michael Figuiere, Minh Do, Netfl...
Tuning Speculative Retries to Fight Latency (Michael Figuiere, Minh Do, Netfl...
DataStax
 
Machine Learning using Kubeflow and Kubernetes
Machine Learning using Kubeflow and Kubernetes
Arun Gupta
 
Java Performance Analysis on Linux with Flame Graphs
Java Performance Analysis on Linux with Flame Graphs
Brendan Gregg
 
Linux BPF Superpowers
Linux BPF Superpowers
Brendan Gregg
 
Resilience4j with Spring Boot
Resilience4j with Spring Boot
Knoldus Inc.
 
Cloud Native Java GraalVM 이상과 현실
Cloud Native Java GraalVM 이상과 현실
Taewan Kim
 

Similar to JavaScript for ABAP Programmers - 2/7 Data Types (20)

WT Unit-3 PPT.pptx
WT Unit-3 PPT.pptx
TusharTikia
 
javascript
javascript
Kaya Ota
 
JavaScript Data Types
JavaScript Data Types
Charles Russell
 
Java script summary
Java script summary
maamir farooq
 
data-types-operators-datatypes-operators.ppt
data-types-operators-datatypes-operators.ppt
Gagan Rana
 
JavaScript: Values, Types and Variables
JavaScript: Values, Types and Variables
LearnNowOnline
 
Javascript analysis
Javascript analysis
Uchitha Bandara
 
02. Data Type and Variables
02. Data Type and Variables
Tommy Vercety
 
Java script session 3
Java script session 3
Saif Ullah Dar
 
An introduction to javascript
An introduction to javascript
MD Sayem Ahmed
 
JavaScript Programming
JavaScript Programming
Sehwan Noh
 
Introduction to JavaScript for APEX Developers - Module 1: JavaScript Basics
Introduction to JavaScript for APEX Developers - Module 1: JavaScript Basics
Daniel McGhan
 
chap04.ppt
chap04.ppt
Varsha Uchagaonkar
 
Module 1: JavaScript Basics
Module 1: JavaScript Basics
Daniel McGhan
 
Ajax and JavaScript Bootcamp
Ajax and JavaScript Bootcamp
AndreCharland
 
copa-ii.pptx
copa-ii.pptx
ERHariramPrajapat
 
Java script
Java script
Abhishek Kesharwani
 
Javascript
Javascript
Prashant Kumar
 
Datatype in JavaScript
Datatype in JavaScript
Rajat Saxena
 
Javascript
Javascript
20261A05H0SRIKAKULAS
 
WT Unit-3 PPT.pptx
WT Unit-3 PPT.pptx
TusharTikia
 
javascript
javascript
Kaya Ota
 
data-types-operators-datatypes-operators.ppt
data-types-operators-datatypes-operators.ppt
Gagan Rana
 
JavaScript: Values, Types and Variables
JavaScript: Values, Types and Variables
LearnNowOnline
 
02. Data Type and Variables
02. Data Type and Variables
Tommy Vercety
 
An introduction to javascript
An introduction to javascript
MD Sayem Ahmed
 
JavaScript Programming
JavaScript Programming
Sehwan Noh
 
Introduction to JavaScript for APEX Developers - Module 1: JavaScript Basics
Introduction to JavaScript for APEX Developers - Module 1: JavaScript Basics
Daniel McGhan
 
Module 1: JavaScript Basics
Module 1: JavaScript Basics
Daniel McGhan
 
Ajax and JavaScript Bootcamp
Ajax and JavaScript Bootcamp
AndreCharland
 
Datatype in JavaScript
Datatype in JavaScript
Rajat Saxena
 
Ad

Recently uploaded (20)

AudGram Review: Build Visually Appealing, AI-Enhanced Audiograms to Engage Yo...
AudGram Review: Build Visually Appealing, AI-Enhanced Audiograms to Engage Yo...
SOFTTECHHUB
 
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Alliance
 
ENERGY CONSUMPTION CALCULATION IN ENERGY-EFFICIENT AIR CONDITIONER.pdf
ENERGY CONSUMPTION CALCULATION IN ENERGY-EFFICIENT AIR CONDITIONER.pdf
Muhammad Rizwan Akram
 
Crypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdf
Stephen Perrenod
 
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc
 
High Availability On-Premises FME Flow.pdf
High Availability On-Premises FME Flow.pdf
Safe Software
 
Data Validation and System Interoperability
Data Validation and System Interoperability
Safe Software
 
Oracle Cloud Infrastructure Generative AI Professional
Oracle Cloud Infrastructure Generative AI Professional
VICTOR MAESTRE RAMIREZ
 
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Alliance
 
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
AmirStern2
 
Supporting the NextGen 911 Digital Transformation with FME
Supporting the NextGen 911 Digital Transformation with FME
Safe Software
 
Introduction to Typescript - GDG On Campus EUE
Introduction to Typescript - GDG On Campus EUE
Google Developer Group On Campus European Universities in Egypt
 
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
Safe Software
 
MuleSoft for AgentForce : Topic Center and API Catalog
MuleSoft for AgentForce : Topic Center and API Catalog
shyamraj55
 
The State of Web3 Industry- Industry Report
The State of Web3 Industry- Industry Report
Liveplex
 
Oracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization Program
VICTOR MAESTRE RAMIREZ
 
Mastering AI Workflows with FME - Peak of Data & AI 2025
Mastering AI Workflows with FME - Peak of Data & AI 2025
Safe Software
 
PyData - Graph Theory for Multi-Agent Integration
PyData - Graph Theory for Multi-Agent Integration
barqawicloud
 
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Shashikant Jagtap
 
Your startup on AWS - How to architect and maintain a Lean and Mean account
Your startup on AWS - How to architect and maintain a Lean and Mean account
angelo60207
 
AudGram Review: Build Visually Appealing, AI-Enhanced Audiograms to Engage Yo...
AudGram Review: Build Visually Appealing, AI-Enhanced Audiograms to Engage Yo...
SOFTTECHHUB
 
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Alliance
 
ENERGY CONSUMPTION CALCULATION IN ENERGY-EFFICIENT AIR CONDITIONER.pdf
ENERGY CONSUMPTION CALCULATION IN ENERGY-EFFICIENT AIR CONDITIONER.pdf
Muhammad Rizwan Akram
 
Crypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdf
Stephen Perrenod
 
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc
 
High Availability On-Premises FME Flow.pdf
High Availability On-Premises FME Flow.pdf
Safe Software
 
Data Validation and System Interoperability
Data Validation and System Interoperability
Safe Software
 
Oracle Cloud Infrastructure Generative AI Professional
Oracle Cloud Infrastructure Generative AI Professional
VICTOR MAESTRE RAMIREZ
 
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Alliance
 
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
AmirStern2
 
Supporting the NextGen 911 Digital Transformation with FME
Supporting the NextGen 911 Digital Transformation with FME
Safe Software
 
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
Safe Software
 
MuleSoft for AgentForce : Topic Center and API Catalog
MuleSoft for AgentForce : Topic Center and API Catalog
shyamraj55
 
The State of Web3 Industry- Industry Report
The State of Web3 Industry- Industry Report
Liveplex
 
Oracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization Program
VICTOR MAESTRE RAMIREZ
 
Mastering AI Workflows with FME - Peak of Data & AI 2025
Mastering AI Workflows with FME - Peak of Data & AI 2025
Safe Software
 
PyData - Graph Theory for Multi-Agent Integration
PyData - Graph Theory for Multi-Agent Integration
barqawicloud
 
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Shashikant Jagtap
 
Your startup on AWS - How to architect and maintain a Lean and Mean account
Your startup on AWS - How to architect and maintain a Lean and Mean account
angelo60207
 
Ad

JavaScript for ABAP Programmers - 2/7 Data Types

  • 1. JavaScript for ABAP Programmers Data Types Chris Whealy / The RIG
  • 2. ABAP Strongly typed Syntax similar to COBOL Block Scope No equivalent concept OO using class based inheritance Imperative programming JavaScript Weakly typed Syntax derived from Java Lexical Scope Functions are 1st class citizens OO using referential inheritance Imperative or Functional programming
  • 3. Strongly Typed vs. Weakly Typed Languages There are two schools of thought for determining how data should be stored in variables: • ABAP uses Strong (or Static) Typing Apart from field symbols, all ABAP variables must have their data type defined at declaration time © 2013 SAP AG. All rights reserved. 3
  • 4. Strongly Typed vs. Weakly Typed Languages There are two schools of thought for determining how data should be stored in variables: • ABAP uses Strong (or Static) Typing • JavaScript uses Weak (or Dynamic) Typing Apart from field symbols, all ABAP variables A variable takes on the data type of whatever must have their data type defined at declaration value it currently holds time © 2013 SAP AG. All rights reserved. 4
  • 5. Strongly Typed vs. Weakly Typed Languages There are two schools of thought for determining how data should be stored in variables: • ABAP uses Strong (or Static) Typing • JavaScript uses Weak (or Dynamic) Typing Apart from field symbols, all ABAP variables A variable takes on the data type of whatever must have their data type defined at declaration value it currently holds time • Pros and Cons of Strong Typing + Data type errors can be trapped at compile time - Rigid type systems reduce language flexibility © 2013 SAP AG. All rights reserved. 5
  • 6. Strongly Typed vs. Weakly Typed Languages There are two schools of thought for determining how data should be stored in variables: • ABAP uses Strong (or Static) Typing • JavaScript uses Weak (or Dynamic) Typing Apart from field symbols, all ABAP variables A variable takes on the data type of whatever must have their data type defined at declaration value it currently holds time • Pros and Cons of Strong Typing • Pros and Cons of Weak Typing + Data type errors can be trapped at compile time - Rigid type systems reduce language flexibility - Data type errors can only be trapped at runtime + Highly flexible type system allows for a dynamic style of coding © 2013 SAP AG. All rights reserved. 6
  • 7. Strongly Typed vs. Weakly Typed Languages There are two schools of thought for determining how data should be stored in variables: • ABAP uses Strong (or Static) Typing • JavaScript uses Weak (or Dynamic) Typing Apart from field symbols, all ABAP variables A variable takes on the data type of whatever must have their data type defined at declaration value it currently holds time • Pros and Cons of Strong Typing • Pros and Cons of Weak Typing + Data type errors can be trapped at compile time - Rigid type systems reduce language flexibility - Data type errors can only be trapped at runtime + Highly flexible type system allows for a dynamic style of coding Compiled languages (E.G. ABAP, Java, C) tend to use strong typing, whereas interpreted scripting languages (E.G. JavaScript, Ruby, Python) tend to use weak typing. © 2013 SAP AG. All rights reserved. 7
  • 8. JavaScript Data Types: Overview In JavaScript, there are only 6 data types. At any one time the value of a variable belongs to one and only one of the following data types. Data Type This value of this variable… Null Is explicitly defined as having no value Undefined Is indeterminate Boolean Is either true or false String Is an immutable collection of zero or more Unicode characters Number Can be used in mathematical operations Object Is an unordered collection of name/value pairs © 2013 SAP AG. All rights reserved. 8
  • 9. JavaScript Data Types 1/3 In the coding, the data types are specified as follows: // -----------------------------------------------------------------------------------------------// Special null; // Indicates an explicit non-value undefined; // Indicates an indeterminate value (E.G. a variable is declared but not initialised) © 2013 SAP AG. All rights reserved. 9
  • 10. JavaScript Data Types 1/3 In the coding, the data types are specified as follows: // -----------------------------------------------------------------------------------------------// Special null; // Indicates an explicit non-value undefined; // Indicates an indeterminate value (E.G. a variable is declared but not initialised) // -----------------------------------------------------------------------------------------------// Boolean true; false; © 2013 SAP AG. All rights reserved. 10
  • 11. JavaScript Data Types 1/3 In the coding, the data types are specified as follows: // -----------------------------------------------------------------------------------------------// Special null; // Indicates an explicit non-value undefined; // Indicates an indeterminate value (E.G. a variable is declared but not initialised) // -----------------------------------------------------------------------------------------------// Boolean true; false; // -----------------------------------------------------------------------------------------------// String – contains zero or more Unicode characters 'Bazinga!'; // Can be delimited by either single quotes ""; // Or double quotes © 2013 SAP AG. All rights reserved. 11
  • 12. JavaScript Data Types 2/3 In the coding, the data types are specified as follows: // -----------------------------------------------------------------------------------------------// Number 3.1415926; // Stored as 64-bit floating point number 1; // Be careful, this is stored as floating point value, not an integer! © 2013 SAP AG. All rights reserved. 12
  • 13. JavaScript Data Types 2/3 In the coding, the data types are specified as follows: // -----------------------------------------------------------------------------------------------// Number 3.1415926; // Stored as 64-bit floating point number 1; // Be careful, this is stored as floating point value, not an integer! // Warning! All the usual problems associated with trying to represent decimal values in binary // floating point format still apply in JavaScript! var result = 0.1 + 0.2; result; //  0.30000000000000004, not 0.3 (Decimal 0.1 has no exact binary equivalent) © 2013 SAP AG. All rights reserved. 13
  • 14. JavaScript Data Types 2/3 In the coding, the data types are specified as follows: // -----------------------------------------------------------------------------------------------// Number 3.1415926; // Stored as 64-bit floating point number 1; // Be careful, this is stored as floating point value, not an integer! // Warning! All the usual problems associated with trying to represent decimal values in binary // floating point format still apply in JavaScript! var result = 0.1 + 0.2; result; //  0.30000000000000004, not 0.3 (Decimal 0.1 has no exact binary equivalent) // Special numerical values that could be returned in the event of illegal mathematical operations // (These values are actually stored as properties of the Global Object) NaN; // 'Not a Number' E.G. 1/'cat'  NaN Infinity; // The result of division by zero © 2013 SAP AG. All rights reserved. 14
  • 15. JavaScript Data Types 3/3 In addition to the basic data type of Object, JavaScript provides several built-in objects that behave as if they were composite data types. E.G. Array, Date, Function, Math and RegEx etc. // -----------------------------------------------------------------------------------------------// Object. Zero or more unordered name:value pairs of any data type delimited by curly braces { pet1: 'cat', pet2: 'dog' }; © 2013 SAP AG. All rights reserved. 15
  • 16. JavaScript Data Types 3/3 In addition to the basic data type of Object, JavaScript provides several built-in objects that behave as if they were composite data types. E.G. Array, Date, Function, Math and RegEx etc. // -----------------------------------------------------------------------------------------------// Object. Zero or more unordered name:value pairs of any data type delimited by curly braces { pet1: 'cat', pet2: 'dog' }; // Array object. Zero or more values of any data type accessed by a numerical, 0 based index [1,2,3,4,5]; © 2013 SAP AG. All rights reserved. 16
  • 17. JavaScript Data Types 3/3 In addition to the basic data type of Object, JavaScript provides several built-in objects that behave as if they were composite data types. E.G. Array, Date, Function, Math and RegEx etc. // -----------------------------------------------------------------------------------------------// Object. Zero or more unordered name:value pairs of any data type delimited by curly braces { pet1: 'cat', pet2: 'dog' }; // Array object. Zero or more values of any data type accessed by a numerical, 0 based index [1,2,3,4,5]; // Function object. A special object that has both properties and executable content function() { /* statements */ } © 2013 SAP AG. All rights reserved. 17
  • 18. JavaScript Data Types 3/3 In addition to the basic data type of Object, JavaScript provides several built-in objects that behave as if they were composite data types. E.G. Array, Date, Function, Math and RegEx etc. // -----------------------------------------------------------------------------------------------// Object. Zero or more unordered name:value pairs of any data type delimited by curly braces { pet1: 'cat', pet2: 'dog' }; // Array object. Zero or more values of any data type accessed by a numerical, 0 based index [1,2,3,4,5]; // Function object. A special object that has both properties and executable content function() { /* statements */ } // Math object. Contains many useful mathematical functions and constants Math.PI; //  3.141592653589793 © 2013 SAP AG. All rights reserved. 18
  • 19. JavaScript Data Types 3/3 In addition to the basic data type of Object, JavaScript provides several built-in objects that behave as if they were composite data types. E.G. Array, Date, Function, Math and RegEx etc. // -----------------------------------------------------------------------------------------------// Object. Zero or more unordered name:value pairs of any data type delimited by curly braces { pet1: 'cat', pet2: 'dog' }; // Array object. Zero or more values of any data type accessed by a numerical, 0 based index [1,2,3,4,5]; // Function object. A special object that has both properties and executable content function() { /* statements */ } // Math object. Contains many useful mathematical functions and constants Math.PI; //  3.141592653589793 // Regular Expression Object. A tool for specifying and extracting patterns of text within a string /^(?:([A-Za-z]+):)?(/{0,3})([0-9.-A-Za-z]+)(?::(d+))?(?:/([^?#]*))?(?:?([^#]*))?(?:#(.*))?$/; © 2013 SAP AG. All rights reserved. 19
  • 20. JavaScript Data Types 3/3 In addition to the basic data type of Object, JavaScript provides several built-in objects that behave as if they were composite data types. E.G. Array, Date, Function, Math and RegEx etc. // -----------------------------------------------------------------------------------------------// Object. Zero or more unordered name:value pairs of any data type delimited by curly braces { pet1: 'cat', pet2: 'dog' }; // Array object. Zero or more values of any data type accessed by a numerical, 0 based index [1,2,3,4,5]; // Function object. A special object that has both properties and executable content function() { /* statements */ } // Math object. Contains many useful mathematical functions and constants Math.PI; //  3.141592653589793 // Regular Expression Object. A tool for specifying and extracting patterns of text within a string // Regular expressions are sometimes confused with Egyptian hieroglyphics... :-) © 2013 SAP AG. All rights reserved. 20
  • 21. Variables and Data Types In weakly typed languages such as JavaScript, there is no concept of declaring that a variable should hold data of a particular type. The data type of a variable is determined simply by the value it currently holds. // A weakly typed language means that data types are determined // dynamically at runtime, not statically at design time var whoAmI = 'Hello world'; © 2013 SAP AG. All rights reserved. // Variable 'whoAmI' is both declared & assigned a string value 21
  • 22. Variables and Data Types In weakly typed languages such as JavaScript, there is no concept of declaring that a variable should hold data of a particular type. The data type of a variable is determined simply by the value it currently holds. // A weakly typed language means that data types are determined // dynamically at runtime, not statically at design time var whoAmI = 'Hello world'; // Variable 'whoAmI' is both declared & assigned a string value whoAmI = 1.61792; whoAmI = [1,2,3,4,5]; // Now it's a number // Now it's an array © 2013 SAP AG. All rights reserved. 22
  • 23. Variables and Data Types In weakly typed languages such as JavaScript, there is no concept of declaring that a variable should hold data of a particular type. The data type of a variable is determined simply by the value it currently holds. // A weakly typed language means that data types are determined // dynamically at runtime, not statically at design time var whoAmI = 'Hello world'; // Variable 'whoAmI' is both declared & assigned a string value whoAmI = 1.61792; whoAmI = [1,2,3,4,5]; // Now it's a number // Now it's an array whoAmI = true; // Now it's a Boolean © 2013 SAP AG. All rights reserved. 23
  • 24. Variables and Data Types In weakly typed languages such as JavaScript, there is no concept of declaring that a variable should hold data of a particular type. The data type of a variable is determined simply by the value it currently holds. // A weakly typed language means that data types are determined // dynamically at runtime, not statically at design time var whoAmI = 'Hello world'; // Variable 'whoAmI' is both declared & assigned a string value whoAmI = 1.61792; whoAmI = [1,2,3,4,5]; // Now it's a number // Now it's an array whoAmI = true; // Now it's a Boolean whoAmI = { // Now it's an object someProperty: 'Hello world' } © 2013 SAP AG. All rights reserved. 24
  • 25. Variables and Data Types In weakly typed languages such as JavaScript, there is no concept of declaring that a variable should hold data of a particular type. The data type of a variable is determined simply by the value it currently holds. // A weakly typed language means that data types are determined // dynamically at runtime, not statically at design time var whoAmI = 'Hello world'; // Variable 'whoAmI' is both declared & assigned a string value whoAmI = 1.61792; whoAmI = [1,2,3,4,5]; // Now it's a number // Now it's an array whoAmI = true; // Now it's a Boolean whoAmI = { // Now it's an object someProperty: 'Hello world' } whoAmI = function() { }; © 2013 SAP AG. All rights reserved. // Now it's a...you get the idea 25