Configure JavaScript Code Snippets in VSCode
lessonDuration 2m 55sFree
In this lesson, we learn the basics of creating code snippets in VScode.
Browse
Find courses, lessons, articles, talks, and podcasts.
793 results for "JavaScript"
Showing 241–264 · Page 11 of 34
lessonDuration 2m 55sFree
In this lesson, we learn the basics of creating code snippets in VScode.
lessonDuration 2m 21s
Breadth first search is a graph search algorithm that starts at one node and visits neighboring nodes as widely as possible before going further down any other path. This algorithm requires the use of a queue to keep track of which nodes to visit, so it might be worth your time to brush up on that data structure before watching this lesson.
lessonDuration 1m 9sFree
When working with closures you'll often hear the words "capture", "wrap", or "enclose". The entire idea behind a closure is to take a variable outside of the function and use that variable inside the function. A closure enables patterns for passing around functions that can manage buffers, caches, and values that can travel with the function.
lessonDuration 9m 30sFree
[Finite State Machines](https://statecharts.github.io/what-is-a-state-machine.html) are an old concept in computer science that help you remain bug-free while you manage complex state interactions in your application. In this lesson, I'll show you how to implement one so you have an understanding of the fundamentals of what they do. This is based on my blog post: [Implementing a simple state machine library in JavaScript](https://kentcdodds.com/blog/implementing-a-simple-state-machine-library-in-javascript)
lessonDuration 40sFree
JavaScript's optional chaining can be used to return prevent errors when accessing properties that do not exist. In order to return a useful value, we can combine optional chaining with null coalescing.
lessonDuration 3m 46s
It can be confusing to understand when and how the .prototype and .__proto__ properties are created and used. They both seem to imply having something to do with prototypal inheritance. This is true but possibly not how you think. We'll review each of these properties' role within prototypal inheritance and how they are used in everyday code.
lessonDuration 3m 35s
Quick sort is another "divide and conquer" algorithm, calling itself recursively to sort our list. With quick sort, we pick an index of our array to be the "pivot". Every item is compared to the pivot, and pushed into a left or right array depending on that comparison. Quick sort is then called on these left and right arrays. This is an efficient algorithm and uses less memory than merge sort. The time complexity of quick sort is `O(n log(n))`. Sorting any list requires at least one pass through the entire list, hence `n`, but increasing the size of our list doesn't lead to a linear or quadratic increase in operations. Each doubling in size only results in one more level of operations.
lessonDuration 4m 22s
Merge sort is a "divide and conquer" algorithm. That is, we break the array down into smaller arrays that are easier and faster to sort; then we stitch the results of calling merge sort on these smaller arrays back together to get our final sorted list. This is a recursive algorithm, which dramatically improves the efficiency of our sort compared to bubble or insertion sort. The worst case scenario for our list is `O(n log(n))`, that is, we must go through every item at least once, hence the first `n`, but with each recursive call we operate on half the data set. This means that when we double `n`, we only get one more operation, instead of `n` number of operations like in bubble or insertion sort.
lessonDuration 2m 45s
Insertion sort is another sorting algorithm that closely resembles how we might sort items in the physical world. We start at the second item in our collection and make the assumption that this item is a sorted list of length 1. We then compare all the items before it and determine if it needs to be "inserted" to the left or right of our item. We then move onto the second item, again comparing it to every item before it in the list, inserting those items correctly. Because this algorithm requires two loops, one inside the other, the worst case scenario of our algorithm still requires a time complexity of `O(n^2)`. This is also an inefficient sorting algorithm, but if our list is mostly sorted already, it will perform a slight bit better than bubble sort.
lessonDuration 3m 14s
Bubble sort is often one of the first sorting algorithms people learn because it closely resembles how we might physically sort a collection of items. We loop through our list of items, comparing our current item with the next one. If our current item is less than the next one, we swap them. We continue looping through the list until we make a loop without any swaps. This is a very inefficient algorithm with a time complexity of `O(n^2)`. Given a list of length `n`, we must compare each item against every other item in the list, which gives us `n * n`, or rather `n^2`. That means for a list of length 10, our worst case scenario will require 100 loops to sort our list. A list just twice as long will take 4x as many loops to solve.
lessonDuration 4m 17s
A binary tree is a tree where each node may only have up to two children. These children are stored on the `left` and `right` properties of each node. When traversing a binary tree, we have three common traversal algorithms: in order, pre-order, and post-order. In this lesson, we write each of these algorithms and explore their differences.
lessonDuration 3m 57s
A tree data structure is a graph without any cycles. I can hear you saying, "Kyle, that's a super helpful explanation," with a healthy dose of sarcasm already. "No cycles" means that no three nodes create a circuitous path. In a tree, nodes have a single parent node and may have many children nodes. They never have more than one parent nor point to any siblings. The most common tree structure you see is a web page. The underlying structure is often called the "DOM tree". The `html` element forms the root of our tree, with children of `head` and `body`, so on and so forth. In this lesson, we'll create a quick example of a DOM tree with our tree data structure.
lessonDuration 1m 50s
Depth first search is a graph search algorithm that starts at one node and uses recursion to travel as deeply down a path of neighboring nodes as possible, before coming back up and trying other paths.
lessonDuration 2m 40s
In this lesson, you'll learn how we can combine several queues to create a new data structure: a priority queue. A priority queue allows the user to add items to the queue that are deemed to be high priority, and get moved ahead in the line. This added complexity is simple to achieve and is a good example of how we can build up complexity through the use of data structures.
lessonDuration 1m 36s
Whether you've studied computer science before and need a refresher, or you're like me and never had the chance to study it in school, my hope is that this course is a great introduction to the concepts of data structures and algorithms. We'll cover queues, stacks, linked lists, graphs and trees, breadth first and depth first search, tree traversal, and a variety of sorting algorithms. The goal of this course isn't for you to be able to implement these from scratch, though that's precisely what we'll do. Instead, the goal is to teach you to think differently, to learn how to use the right tool for the job, to break problems down into their atomic, algorithmic steps, and even to think divergently, to conceive of several solutions to the same problem understand their tradeoffs. These skills will make you a better engineer for sure.
lessonDuration 3m 23s
Functional compositions are purposely opaque, with no obvious way to "visualize" the data as it transforms. This is great when our function works, as it's hard to _add_ bugs, but challenging when our compositions aren't correct. This lesson teaches you how to debug functional compositions by writing and using a `trace()` function to log out our values as they transform. This allows us to continue using pointfree programming while also providing a view into our compositions.
lessonDuration 1m 47s
This lesson teaches you what the associative property is, the mathematical principle that proves the grouping of values in when adding or multiplying does not affect the result and applies it to functional composition. This lesson will demonstrate how we can achieve the same composition with different groupings of smaller compositions. This gives us confidence in our code and the ability to create even greater complexity with compositions.
lessonDuration 4m 37s
This lesson teaches you the concept of composition, the building up of complex functionality through the combining of simpler functions. In a sense, composition is the nesting of functions, passing the result of one in as the input into the next. But rather than create an indecipherable amount of nesting, we'll create a higher order function, `compose()`, that takes all of the functions we want to combine, and returns us a new function to use in our app.
lessonDuration 1m 23s
This lesson teaches you what pointfree programming is, passing a named function as an argument to avoid writing an anonymous function with interim variables instead. Pointfree programming increases code legibility, decreases the surface area for bugs, and makes our code more composable and unit testable. We will demonstrate this by removing the anonymous arrow function passed as a callback to a `map` method with a named function.
lessonDuration 2m 57s
This lesson teaches you to order the arguments of your functions following functional programming principles. By ordering our arguments in a specific way, we allow our functions to benefit from partial application, improve reusability, and enable composition of functions. Specifically, we will focus on always providing the data as the last argument to our functions so that the result of one function can be piped as the argument into another function.
lessonDuration 1m 54s
This lesson teaches you how arguments passed to a curried function allow us to store data in closure to be reused in our programs and applications. Since each argument, except for the final one, returns a new function, we can easily create reusable functions by supplying some of these arguments beforehand, and sharing these partially applied functions with other parts of our codebase. In this lesson, we'll create a curried function to fetch requests from an API that uses partial application to create reusable functionality.
lessonDuration 1m 50s
This lesson teaches you what currying is: the act of refactoring a function so that it receives its arguments one at a time. We will use the canonical example of an add function to demonstrate this. This lesson also teaches the concept of “arity”, the number of arguments a function receives, as it is useful knowledge for functional programming.
lessonDuration 4m 27s
This lesson teaches you the difference between pure and impure functions through examples of both. Pure functions are any functions whose output is solely derived from its inputs and causes no side effects in the application or outside world. Mathematical functions are examples of pure functions. Impure functions come in a variety of shapes and sizes. Some typical examples would be: * Functions whose output depends on outside/global state * Functions that return different outputs for the same inputs * Functions that modify application state * Functions that modify the "outside world" Functional programming is built upon the use of pure functions and the strict control of side effects. Being able to recognize either type of function is a key fundamental for functional programming.
lessonDuration 2m 40s
We want to be able to pick nine random cards from an array of twelve cards, but can run into problems of keeping both the cards already draw and the cards left to draw from. Tracking two bits of state like this can create some hard to maintain argument gymnastics when creating our functions. Luckily we have a datatype `Pair` at our disposal that allows us to combine two values in to one value. We will use this `Pair` type to model both a draw pile and a remaining pile, and take advantage of a couple special properties of `Pair` that will allow us to combine two `Pair` instances in a meaningful way by `chain`ing. Just like we have done time and time again with the `State` ADT