Today I Learned - Rocky Kev

Tagged “advanced”

  1. TIL not using try/catch block with promises for error catching

    You shouldn't use a try/catch block inside the Promise Definition. Your promise is already doing that.

  2. TIL using proxies for reactivity

    A Proxy let you detect when someone gets, sets, or updates a property on an object, and run code when they do. But why? This usecase -- when you add/update the object, it also updates localStorage!

  3. TIL the difference between partial application and currying

    Partial application transforms a function into another function with smaller set of arguments. Currying creates nesting functions according to the number of the arguments of the function. Each function receives an argument.

  4. TIL how to convert a Callback to a Promise

    Callback functions work well for simple asynchronous operations, but can become difficult to manage and lead to 'callback hell' when dealing with more complex operations. Promises follow a specific pattern.

  5. TIL A practical Curry Example

    Currying is a programming technique where you take a function with multiple arguments, and you turn it into smaller sequential functions where you pass one argument at a time. But many use-cases kinda suck

  6. TIL use-cases for Generators in Javascript

    Generators are functions that can be exited and later re-entered. Their context (variable bindings) will be saved across re-entrances.

  7. TIL Memoization performance

    Memorization in a nutshell: You catch the data if it exists already.

  8. TIL Why use Closures

    Now you might be asking, why even use it? Why not just flatten it out so it's just one function with one return statement?

  9. TIL refactoring object lookups to avoid looking at the prototype chain

    Depending on your lookup method, you can access the prototype chain, which opens up some potential vulnerabilities or terrible side effects!

  10. TIL about semaphores

    A semaphore limits access to a resource to some number of consumers. Any new requests for the resource will get stalled until later, eventually to be handled.

  11. TIL ES6 Proxy's apply method

    Using JavaScript proxies you can wrap an existing object and intercept access to its attributes or methods, even if they don’t exist. You can also redefine fundamental operations for that object.

  12. TIL ES6 Proxy

    Using JavaScript proxies you can wrap an existing object and intercept access to its attributes or methods, even if they don’t exist. You can also redefine fundamental operations for that object.

  13. TIL about more examples of currying

    Currying is nothing more than a way to transform functions that accept multiple parameters into a sequential list of functions that take only one parameter each.

  14. TIL what Single Threaded & Non-blocking means in JS

    Javascript is a single-threaded language. This means it has one call stack and one memory heap. Non-blocking means it'll read from top to bottom and throw anything async in the queue.

  15. TIL about switching out of JS Classes and into JS Modules

    A classes are just blueprints for creating objects. A class encapsulates data and functions that manipulate data. A module is a file that exports features, such as variables, objects, and functions, that can be used elsewhere.

  16. TIL Vue's Render Function

    A good example is that you want to generate a lot of list items, and writing them in the '<template>' section makes it look like spaghetti.

  17. TIL solving the this keyword and it's execution context

    The this keyword references the current execution context of the function from where you’re calling using it. If it's used in a regular function, a arrow function, or a method changes the execution context of this.

  18. TIL Microtask Queue vs the Call Stack Queue

    When everything is done from the 'Call Stack', the Event Loop finds some new tasks to go after. It'll dig through all the 'Microtasks queues', then in the 'Macrotasks queues'.

  19. TIL all functions create a empty prototype object

    When you create a function in JavaScript, it automatically creates an empty container called prototype for you to stick your methods into.

  20. TIL hoisting based on function declarations & function expressions

    Function declarations get hoisted on load. So you can use it anywhere. Function expressions do not. Neither are better than another

  21. TIL Immediately Invoked Function Expression

    This is a design pattern where you create a function expression that is immediately executed.

  22. TIL Closure as a backpack

    The Backpack concept is a mental model to think about how closure saves data behind the scenes.

  23. TIL Closures in Private Methods

    Closure in JS: Private data

  24. TIL a Closure example with class-like methods

    Closure in JS: Nesting functions

  25. TIL Javascript Closures

    The answer to var a = add(2)(3); //5

See all tags.