Advertisement
Guest User

Untitled

a guest
Aug 2nd, 2015
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. // Javascript
  2.  
  3. // Brendan Eich was the inventor and it took him 240 hours
  4. // Has some problems but became compatible by Ecma
  5. // called Mocha then LiveScript then JavaScript
  6.  
  7. // Brendan Eich is working on Web Assembly
  8. // www.destryallsoftware.com/talks/wat
  9.  
  10. // Extend JavaScript with...
  11. D3js
  12. EmberJS
  13. Node
  14. Quake
  15.  
  16. var fizzbuzz = function(num) {
  17. var f = num%3 === 0
  18. var b = num%5 === 0
  19. };
  20.  
  21. var fizzbuzz = function(num) {
  22. var f, b;
  23. f = num%3 === 0;
  24. f = num%5 === 0
  25. };
  26.  
  27. var fizzbuzz = function(num){
  28. var f = num%3 === 0, b = num%5 === 0;
  29. return f ? b ? "FizzBuzz" : "Fizz" : b ? "Buzz" : num;
  30. };
  31.  
  32. }
  33.  
  34. // JS CONTINUED
  35.  
  36. var firstName = 'Yngwue';
  37. // After keywords that are commands
  38. continue;
  39. return "Hi";
  40. break;
  41.  
  42. // ; in loops
  43. for (i = 5; i; i--) {
  44. console.log();
  45. }
  46.  
  47. 'use strict';
  48.  
  49. // Scope
  50. function return();
  51. return name;
  52. }
  53.  
  54. retunName(); //nothing
  55.  
  56. var name = "Steven";
  57.  
  58. function returnName(){
  59. return name;
  60. }
  61.  
  62. returnName(); // "Steven Works great!
  63.  
  64. function setName(newName){
  65. var name = newName;
  66. }
  67.  
  68. setName("Steven");
  69. name; //undefined
  70.  
  71. // env scope
  72. var name;
  73. function setName(newName){
  74. name = newName;
  75. }
  76.  
  77. setName("Steven");
  78. name; // "Steven"
  79.  
  80. // IIFE
  81. var secret;
  82. (function myFunction(){
  83. secret = 42;
  84. })();
  85. secret; // 42 mah sekretz
  86.  
  87. // arrays
  88. var array = [];
  89. array.push("Denise");
  90. array.forEach(function(techer))
  91. console.log(teacher);
  92. })
  93.  
  94. //hashes
  95. var teachers = {
  96. avi: "Rails",
  97. steven: "JavaScript",
  98. jonathon: "HTML & CSS"
  99. }
  100.  
  101. for(var teacher in teachers){
  102. console.log(teacher + " teaches " + teachers[teacher])}
  103. }
  104.  
  105. var steven = {
  106. name: "Steven",
  107. introduce: function(){
  108. return "Hi! I'm " + this.name;
  109. }
  110. }
  111.  
  112. steven.introduce(); //Hi! I'm Steven
  113.  
  114. var num_array = [1, 2, 3, 4, 5]
  115. for(i; i < cars.length; i++)
  116. console.log("Value of local veriable:" + string(i));
  117. end
  118. }
  119. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement