Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2017
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.13 KB | None | 0 0
  1. var myArray = Array();
  2. myArray['A'] = "Athens";
  3. myArray['B'] = "Berlin";
  4.  
  5. var myObject = {'A': 'Athens', 'B':'Berlin'};
  6.  
  7. var myArray = Array();
  8. myArray['A'] = "Athens";
  9. myArray['B'] = "Berlin";
  10.  
  11. alert(myArray.length);
  12.  
  13. concat
  14. every
  15. filer
  16. forEach
  17. join
  18. indexOf
  19. lastIndexOf
  20. map
  21. pop
  22. push
  23. reverse
  24. shift
  25. slice
  26. some
  27. sort
  28. splice
  29. toSource
  30. toString
  31. unshift
  32. valueOf
  33.  
  34. javascript:alert([].length+'n'+{}.length)
  35.  
  36. javascript:
  37. ra=[ "one", "two", "three"]; ra.a=4;
  38. ob={0:"one", 1:"two", 2:"three"}; ob.a=4;
  39. alert(
  40. ra +"nn"+
  41. ob +"nn"+
  42. ra.toSource() +"nn"+
  43. ra.a +"t .toSource() forgot me! nn"+
  44. ra.length +"t and my length! nn"+
  45. ob.toSource());
  46. ps=""; for(i in ra)ps+=i+" "; alert(ps); /* NB .length is missing! */
  47. ps=""; for(i in ob)ps+=i+" "; alert(ps);
  48.  
  49. javascript:
  50. ra=[ "one", "two", "three"]; ra.a=4;
  51. ob={0:"one", 1:"two", 2:"three"}; ob.a=4;
  52. alert(
  53. ra +"nn"+
  54. ob +"nn"+
  55. ra.toSource() +"nn"+
  56. ra.a +"t .toSource() forgot me! nn"+
  57. ra.length +"t and my length! nn"+
  58. ob.toSource());
  59. ps=""; for(i in ra)ps+=i+" "; alert(ps); /* NB .length is missing! */
  60. ps=""; for(i in ob)ps+=i+" "; alert(ps);
  61.  
  62. 0 1 2 a
  63.  
  64. javascript:
  65. alert([Array, Boolean, Date, Function,
  66. Number, Object, RegExp, String] . join('nn') );
  67.  
  68. function Array() {
  69. [native code]
  70. }
  71.  
  72. function Boolean() {
  73. [native code]
  74. }
  75.  
  76. function Date() {
  77. [native code]
  78. }
  79.  
  80. function Function() {
  81. [native code]
  82. }
  83.  
  84. function Number() {
  85. [native code]
  86. }
  87.  
  88. function Object() {
  89. [native code]
  90. }
  91.  
  92. function RegExp() {
  93. [native code]
  94. }
  95.  
  96. function String() {
  97. [native code]
  98. }
  99.  
  100. javascript:alert([Math, JSON, true.toSource()].join("nn"));
  101.  
  102. [object Math]
  103.  
  104. [object JSON]
  105.  
  106. (new Boolean(true))
  107.  
  108. var myArray = Array();
  109.  
  110. var myObject = {'A': 'Athens', 'B':'Berlin'};
  111.  
  112. alert(myArray.constructor)
  113. alert(myObject.constructor)
  114.  
  115. var Func = new Function("<params>", "<code>");
  116.  
  117. var a = [];
  118. a['name'] = 'John';
  119. JSON.stringify(a); // will output '[]'
  120.  
  121. var b = {};
  122. b['name'] = 'John';
  123. JSON.stringify(b); // will output '{"name":"John"}'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement