Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Couple-O-Points
● JavaScript is a “loosely typed” or “dynamic”
language.
● So we don’t have to declare type of a variable
...
Data Types in JavaScript
● Numbers
● Strings
● Boolean
● Objects
● Undefined
● Null
Numbers
● JavaScript has single number type
● It is represented as 64-bit floating point
● No separate type of Integer (li...
Strings
● Set of “elements” of 16-bit unsigned integer values.
● Each element in the String occupies a position in String
...
Boolean
● Represents logical entity
● Can have two values
– true
– false
Objects
● Objects are collection of properties
● Properties can be removed and added, after
object has been created
● Obje...
Undefined
● It’s a property of global object
● A variable that has not been assigned a value is
of type undefined.
● A fun...
Null
● Represents absence of any object value
● Operation “typeof null” yields “object”
Exercise
● What are the differences between “null” and
“undefined”?
● How would you test that a variable is defined
and ha...
Exercise
● What are the differences between “null” and
“undefined”?
● How would you test that a variable is defined
and ha...
Upcoming SlideShare
Loading in …5
×

Datatype in JavaScript

104 views

Published on

This is a slide I prepared for my YouTube tutorial.

Published in: Education
  • Be the first to comment

Datatype in JavaScript

  1. 1. Couple-O-Points ● JavaScript is a “loosely typed” or “dynamic” language. ● So we don’t have to declare type of a variable ahead of time. ● You can check the type of any variable using ‘typeof’ operator
  2. 2. Data Types in JavaScript ● Numbers ● Strings ● Boolean ● Objects ● Undefined ● Null
  3. 3. Numbers ● JavaScript has single number type ● It is represented as 64-bit floating point ● No separate type of Integer (like Java etc.) ● 2e3 means 2000 i.e 2 multiplied by 10 raised to the power after ‘e’ symbol. ● In addition, Number type also has three symbolic values – Infinity – -Infinity – NaN
  4. 4. Strings ● Set of “elements” of 16-bit unsigned integer values. ● Each element in the String occupies a position in String ● Strings are immutable ● Strings have methods, useful ones, like: – length() – ToUpperCase() ● New strings can be made using concatenation (‘+’) operator. Interesting case: – ‘r’ + ‘a’ + ‘j’ === ‘raj’
  5. 5. Boolean ● Represents logical entity ● Can have two values – true – false
  6. 6. Objects ● Objects are collection of properties ● Properties can be removed and added, after object has been created ● Object is a mapping between keys and values – A key value is either a symbol or string value – Values can be of any type i.e Number, Boolean, Object etc ● Objects are mutable.
  7. 7. Undefined ● It’s a property of global object ● A variable that has not been assigned a value is of type undefined. ● A function returns undefined if a value was not returned.
  8. 8. Null ● Represents absence of any object value ● Operation “typeof null” yields “object”
  9. 9. Exercise ● What are the differences between “null” and “undefined”? ● How would you test that a variable is defined and has a non-null value?
  10. 10. Exercise ● What are the differences between “null” and “undefined”? ● How would you test that a variable is defined and has a non-null value?

×