Web-007 Javascript: © Luxoft Training. All Rights Reserved
Web-007 Javascript: © Luxoft Training. All Rights Reserved
ver. 1.0
http://www.luxoft-training.ru/
© Luxoft Training. All rights reserved
WEB-007 JavaScript
Data types
ver. 1.0
http://www.luxoft-training.ru/
© Luxoft Training. All rights reserved
Data types
• Overview
• Number
• String
• Boolean
• Function
• Object
• Array
• null and undefined values
• Object wrappers for primitive types
• Data type conversion
http://www.luxoft-training.ru/
© Luxoft Training. All rights reserved
Overview
• Strings – “Hello”
• null
• undefined
• You can think of objects as named containers for values, and functions
as procedures that your application can perform
http://www.luxoft-training.ru/
© Luxoft Training. All rights reserved
Overview
http://www.luxoft-training.ru/
© Luxoft Training. All rights reserved
Numbers
http://www.luxoft-training.ru/
© Luxoft Training. All rights reserved
Numbers
• An exponent
• [(+|-)][digits][.digits][(E|e)[(+|-)]digits]
3.14
.333333333333333333
6.02e23 // 6.02 x 1023
1.4738223E-32 // 1.4738223 x 10-32
http://www.luxoft-training.ru/
© Luxoft Training. All rights reserved
Numbers
• +Infinity
• -Infinity
http://www.luxoft-training.ru/
© Luxoft Training. All rights reserved
Numbers
Special values
Constant Meaning
Infinity Special value to represent infinity
NaN Special not-a-number value
Number.MAX_VALUE Largest representable number
Number.MIN_VALUE Smallest (closest to zero) representable
number
Number.NaN Special not-a-number value
Number.POSITIVE_INFINITY Special value to represent infinity
Number.NEGATIVE_INFINITY Special value to represent negative infinity
http://www.luxoft-training.ru/
© Luxoft Training. All rights reserved
Strings
http://www.luxoft-training.ru/
© Luxoft Training. All rights reserved
Strings
Escape sequences
http://www.luxoft-training.ru/
© Luxoft Training. All rights reserved
Strings
Escape sequences
http://www.luxoft-training.ru/
© Luxoft Training. All rights reserved
Strings
http://www.luxoft-training.ru/
© Luxoft Training. All rights reserved
Booleans
• The boolean data type has only two values
• true
• false
• 0, -0, null, false, NaN, undefined, or the empty string ("") – false
• All other values, including any object or the string "false“ - true
http://www.luxoft-training.ru/
© Luxoft Training. All rights reserved
Functions
http://www.luxoft-training.ru/
© Luxoft Training. All rights reserved
Objects
http://www.luxoft-training.ru/
© Luxoft Training. All rights reserved
Arrays
http://www.luxoft-training.ru/
© Luxoft Training. All rights reserved
null and undefined values
null
http://www.luxoft-training.ru/
© Luxoft Training. All rights reserved
null and undefined values
undefined
• undefined value returned when you use either a variable that has been
declared but never had a value assigned to it, or an object property that
does not exist
http://www.luxoft-training.ru/
© Luxoft Training. All rights reserved
Object wrappers
• String class
• Number class
• Boolean class
• A wrapper contains the same primitive data value, but it also defines
properties and methods that can be used to manipulate that data
http://www.luxoft-training.ru/
© Luxoft Training. All rights reserved
Object wrappers
// primitive value
var s = "primitive";
http://www.luxoft-training.ru/
© Luxoft Training. All rights reserved
Data type conversion
Value Context
http://www.luxoft-training.ru/
© Luxoft Training. All rights reserved
Data type conversion
Value Context
http://www.luxoft-training.ru/
© Luxoft Training. All rights reserved
Data type conversion
Value Context
http://www.luxoft-training.ru/
© Luxoft Training. All rights reserved
Data type conversion
http://www.luxoft-training.ru/
© Luxoft Training. All rights reserved
Data types
• Overview
• Number
• String
• Boolean
• Function
• Object
• Array
• null and undefined values
• Object wrappers for primitive types
• Data type conversion
http://www.luxoft-training.ru/
© Luxoft Training. All rights reserved