Data Types



Thursday, September 3, 2009
undefined
                              any variable that has not been
                                   assigned a value ...
null
                              indicates that variable has been
                                declared but defined em...
number

        • values that can be
               processed and calculated

        •      can be positive or negative

...
number




Thursday, September 3, 2009
number calculations




Thursday, September 3, 2009
Math!
                              http://www.w3schools.com/jsref/jsref_obj_math.asp




Thursday, September 3, 2009
string
                              http://www.w3schools.com/jS/js_obj_string.asp




       •      sequence of character...
string characters




Thursday, September 3, 2009
string characters




Thursday, September 3, 2009
everything is
                              zero indexed
                                javascript
                      ...
string characters
                                  (shortcut)




Thursday, September 3, 2009
string characters
                                  (shortcut)




Thursday, September 3, 2009
string escaping
                              cannot use quotes of the same type inside
                                th...
same quotes
                               no escape
                                 FAIL!




Thursday, September 3, 2009
meet the escape
                                character


                                    
Thursday, September 3, 20...
same quotes
                              with escape
                                 WIN!




Thursday, September 3, 2009
same quotes
                               no escape
                                 FAIL!




Thursday, September 3, 2009
same quotes
                              with escape
                                 WIN!




Thursday, September 3, 2009
different quotes

                                   WIN!




Thursday, September 3, 2009
different quotes

                                   WIN!




Thursday, September 3, 2009
string length




Thursday, September 3, 2009
string search




Thursday, September 3, 2009
changing string case




Thursday, September 3, 2009
string to number




Thursday, September 3, 2009
string to number




Thursday, September 3, 2009
string to number




Thursday, September 3, 2009
“class is awesome”.charAt(2)




Thursday, September 3, 2009
“class is awesome”.charAt(2)
                              “a”

Thursday, September 3, 2009
“class is awesome”[0]




Thursday, September 3, 2009
“class is awesome”[0]
                                      “c”

Thursday, September 3, 2009
how do I get the length of
                            “football”



Thursday, September 3, 2009
how do I get the length of
                            “football”
                              “football”.length

Thursda...
“football”.length




Thursday, September 3, 2009
“football”.length
                                     8

Thursday, September 3, 2009
“football”.indexOf(‘e’)




Thursday, September 3, 2009
“football”.indexOf(‘e’)
                                        -1

Thursday, September 3, 2009
“football”.indexOf(‘foot’)




Thursday, September 3, 2009
“football”.indexOf(‘foot’)
                                   0

Thursday, September 3, 2009
what type is: ‘asdf’




Thursday, September 3, 2009
what type is: ‘asdf’
                                  “string”

Thursday, September 3, 2009
what type is: 15




Thursday, September 3, 2009
what type is: 15
                               “number”

Thursday, September 3, 2009
what type is: -’15’




Thursday, September 3, 2009
what type is: -’15’
                                “number”

Thursday, September 3, 2009
10 + 20




Thursday, September 3, 2009
10 + 20
                                30

Thursday, September 3, 2009
boolean
                                          true or false
                              http://www.w3schools.com/jS/...
Upcoming SlideShare
Loading in …5
×

Primitive Data Types

1,519 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,519
On SlideShare
0
From Embeds
0
Number of Embeds
234
Actions
Shares
0
Downloads
34
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Primitive Data Types

  1. 1. Data Types Thursday, September 3, 2009
  2. 2. undefined any variable that has not been assigned a value and any property of an object that does not exist Thursday, September 3, 2009
  3. 3. null indicates that variable has been declared but defined empty Thursday, September 3, 2009
  4. 4. number • values that can be processed and calculated • can be positive or negative • represented internally as a double, accurate to 14 or 15 digits Thursday, September 3, 2009
  5. 5. number Thursday, September 3, 2009
  6. 6. number calculations Thursday, September 3, 2009
  7. 7. Math! http://www.w3schools.com/jsref/jsref_obj_math.asp Thursday, September 3, 2009
  8. 8. string http://www.w3schools.com/jS/js_obj_string.asp • sequence of characters enclosed with quotation marks • can use single or double quotes • cannot use quotes of the same type inside the same type unless they are escaped Thursday, September 3, 2009
  9. 9. string characters Thursday, September 3, 2009
  10. 10. string characters Thursday, September 3, 2009
  11. 11. everything is zero indexed javascript 0 1 2 34 5 678 9 Thursday, September 3, 2009
  12. 12. string characters (shortcut) Thursday, September 3, 2009
  13. 13. string characters (shortcut) Thursday, September 3, 2009
  14. 14. string escaping cannot use quotes of the same type inside the same type unless they are escaped Thursday, September 3, 2009
  15. 15. same quotes no escape FAIL! Thursday, September 3, 2009
  16. 16. meet the escape character Thursday, September 3, 2009
  17. 17. same quotes with escape WIN! Thursday, September 3, 2009
  18. 18. same quotes no escape FAIL! Thursday, September 3, 2009
  19. 19. same quotes with escape WIN! Thursday, September 3, 2009
  20. 20. different quotes WIN! Thursday, September 3, 2009
  21. 21. different quotes WIN! Thursday, September 3, 2009
  22. 22. string length Thursday, September 3, 2009
  23. 23. string search Thursday, September 3, 2009
  24. 24. changing string case Thursday, September 3, 2009
  25. 25. string to number Thursday, September 3, 2009
  26. 26. string to number Thursday, September 3, 2009
  27. 27. string to number Thursday, September 3, 2009
  28. 28. “class is awesome”.charAt(2) Thursday, September 3, 2009
  29. 29. “class is awesome”.charAt(2) “a” Thursday, September 3, 2009
  30. 30. “class is awesome”[0] Thursday, September 3, 2009
  31. 31. “class is awesome”[0] “c” Thursday, September 3, 2009
  32. 32. how do I get the length of “football” Thursday, September 3, 2009
  33. 33. how do I get the length of “football” “football”.length Thursday, September 3, 2009
  34. 34. “football”.length Thursday, September 3, 2009
  35. 35. “football”.length 8 Thursday, September 3, 2009
  36. 36. “football”.indexOf(‘e’) Thursday, September 3, 2009
  37. 37. “football”.indexOf(‘e’) -1 Thursday, September 3, 2009
  38. 38. “football”.indexOf(‘foot’) Thursday, September 3, 2009
  39. 39. “football”.indexOf(‘foot’) 0 Thursday, September 3, 2009
  40. 40. what type is: ‘asdf’ Thursday, September 3, 2009
  41. 41. what type is: ‘asdf’ “string” Thursday, September 3, 2009
  42. 42. what type is: 15 Thursday, September 3, 2009
  43. 43. what type is: 15 “number” Thursday, September 3, 2009
  44. 44. what type is: -’15’ Thursday, September 3, 2009
  45. 45. what type is: -’15’ “number” Thursday, September 3, 2009
  46. 46. 10 + 20 Thursday, September 3, 2009
  47. 47. 10 + 20 30 Thursday, September 3, 2009
  48. 48. boolean true or false http://www.w3schools.com/jS/js_obj_boolean.asp Thursday, September 3, 2009

×