Xah Talk Show 2026-01-28 Ep752 JavaScript in depth, functional programing extreme
Video Summary (Generated by AI, Edited by Human.)
This video, "Xah Ep752 JavaScript in depth, functional programing extreme. technique to avoid variable, for-loop", offers a deep dive into functional programming in JavaScript. The speaker, Xah Lee, shares his insights on best practices and common pitfalls to avoid when writing JavaScript code.
Here's a summary of the key takeaways:
- Introduction to Functional Programming in JavaScript (0:55-1:04): The speaker introduces the concept of functional programming in JavaScript, emphasizing its depth and practical application.
- Recommended Tools and Practices (1:53-2:10):
- Deno format is highly recommended for formatting JavaScript code due to its superiority over npm or NodeJS.
- Fundamental JavaScript Tips (5:42-6:11):
- Avoid var and use let or const for variable declarations.
- Never use double equal (==) for comparisons as it performs automatic type conversion, leading to unpredictable results; instead, always use triple equal (===) for strict comparison.
- Avoiding Common Loops and Operators (6:16-12:29):
- Do not use for...in loops because they iterate over the prototype chain, which is generally not desired. Instead, use Object.keys or for...of loops (introduced in 2015).
- Never use the with statement, as it is now largely disallowed in modern JavaScript environments like Deno due to use strict mode.
- Avoid assigning array elements by index (e.g., array[0] = value) to prevent the creation of "sparse arrays," which can lead to inconsistent behavior with different array methods. Prefer methods like push, pop, shift, unshift, or the newer toSpliced (introduced in 2023) which returns a new array without modifying the original.
- Do not use the delete operator (26:18-27:51) as its return value is unreliable and can lead to misleading indications of success. Instead, Reflect.deleteProperty (introduced in 2015) is recommended for more predictable behavior.
- Never use the arguments object (27:54-31:57) because it was designed before the rest parameter syntax (e.g., ...args) was introduced in 2015, which provides a more explicit and maintainable way to handle an arbitrary number of function arguments.
- Critique of Linters and Introduction of Go Format (14:15-23:28): Xah Lee expresses his disdain for linters, considering them "idiotic" because they don't fully understand programming language grammar and primarily perform text-based style checks. He praises Go Format (Go language's built-in formatter) for revolutionizing code formatting by being bundled with the language, understanding the full grammar, and being capable of reformatting single-line valid code into multi-line, readable code.
- Issues with the constructor Property (33:03-48:48): The constructor property in JavaScript is discussed as being unreliable for determining the creator function of an object because its value can be changed by users at any time.
- Suggest console.assert instead of console.log for verifying code.
- Keyboard Discussion (49:18-52:26): The speaker briefly discusses his current keyboard, the Ultimate Hacking Keyboard 80 (UHK80), and mentions his previous use of the Glove 80 and Kinesis keyboards. He also encourages donations to support his work.
package main import "fmt" func main() { fmt.Printf("%v\n", "hi guys, supreme functional programing") }