JavaScript: Past, Present, and Future - NDC Porto 2020

JavaScript: Past, Present, and Future - NDC Porto 2020

Ah, JavaScript! Like it or not, it's a "tragically important" language that is "eating the world." Hate it? Love it? Avoid it? Embrace it?

This talk will be a parade of face-palm JavaScript fails, stupid JavaScript tricks, and bad jokes sure to get an eye-roll from everyone! Along the way, we may even learn a few mistakes to avoid and tips to make our own JavaScript less terrible!

3ab1249be442027903e1180025340b3f?s=128

David Neal

April 24, 2020
Tweet

Transcript

  1. None
  2. None
  3. None
  4. None
  5. None
  6. None
  7. None
  8. None
  9. None
  10. None
  11. None
  12. > const lol = a + b + c –

    f * ( n + o ); NaN
  13. > NaN >= 0 false

  14. > NaN <= 0 false

  15. > typeof NaN number

  16. ( a + b ) + c = a +

    ( b + c ) // mathematically true > 0.1 + 0.2 === 0.3 false > ( a + b ) + c == a + ( b + c ) ??
  17. > 0.1 + 0.2 0.30000000000000004

  18. > Math.round(0.4999999999999999722444243843710864894092082) 0 > Math.round(0.4999999999999999722444243843710864894092083) 1 I’ve got 99 problems

    but JavaScript ain’t 1.0000000000000009
  19. > [ 2, 10 ].sort() [ 10, 2 ]

  20. > ['10','10','10', '10', '10'].map( parseInt ) [ 10, NaN, 2,

    3, 4 ]
  21. > typeof undefined // undefined > typeof true // boolean

    > typeof "hello" // string > typeof 1 // number > typeof {lol:true} // object > typeof [1,2,3] // object > typeof null // object
  22. > null == 0 // false > null > 0

    // false > null < 0 // false > null >= 0 // true > null <= 0 // true > Number( null ) // 0
  23. > false > null > undefined > "" > 0

    > NaN
  24. > wat.test("javascript"); // true > wat.test("wat r u doin"); //

    false > const wat = /a/g;
  25. // undefined function troll() { return { haha: "ha!" };

    } troll(); // automatic semi-colon
  26. const arr = []; arr[1] = 1; arr[3] = 2;

    arr[10] = 3; arr.length // 11 arr[-1] = 4; arr.s = 5; arr.length // 11
  27. None
  28. None
  29. None
  30. None
  31. None
  32. None
  33. None
  34. None
  35. None
  36. None
  37. None
  38. None
  39. None
  40. None
  41. None
  42. None
  43. None
  44. None
  45. None
  46. None
  47. None
  48. None
  49. None
  50. None
  51. None
  52. None
  53. None
  54. None
  55. None
  56. None
  57. None
  58. None
  59. None
  60. None
  61. None
  62. None
  63. None
  64. None
  65. None
  66. None
  67. None
  68. None
  69. None
  70. None
  71. None
  72. None
  73. None
  74. None
  75. None
  76. None
  77. None
  78. None
  79. None
  80. None
  81. None
  82. None
  83. None
  84. None
  85. None
  86. None
  87. None
  88. None
  89. None
  90. None
  91. None
  92. None
  93. None
  94. None
  95. None
  96. const user1 = { firstName: "David", lastName: "Neal", address: {

    street: "123 Main Street", city: "Nashville", state: "Tennessee" } };
  97. const user1 = { firstName: "David", lastName: "Neal", address: {

    street: "123 Main Street", city: "Nashville", state: "Tennessee" } }; const city = user1?.address?.zipCode;
  98. None
  99. const v1 = falseyNullOrUndefined || "defaultValue";

  100. const v1 = falseyNullOrUndefined || "defaultValue"; const v2 = onlyNullOrUndefined

    ?? "defaultValue";
  101. globalThis = window ?? self ?? global;

  102. Promise.all() –or- Promise.allSettled()

  103. let config; if (production) { config = await import("./config.production.js"); }

    reportBtn.addEventListener("click", async () => { const reporter = await import("./reporter.js); reporter.generateReport(); });
  104. const integers = Array.from(html.matchAll(/[0-9]*/g));

  105. const big = BigInt(Number.MAX_SAFE_INTEGER); const big2 = 9007199254740991n; const evenBigger

    = big + 3000000n;
  106. None
  107. None
  108. None
  109. To boldly go where NaN has undefined before!

  110. None
  111. None
  112. None
  113. None
  114. None
  115. None
  116. Mobile Apps Automation / DevOps Command Line (CLI) Services

  117. None
  118. None
  119. None
  120. None
  121. None
  122. None
  123. None
  124. None
  125. None
  126. None