Skip to content

Javascript Es6 Playlist

[!info] JavaScript ES6 / ES2015 Tutorials

https://youtube.com/playlist?list=PLillGF-RfqbZ7s3t6ZInY3NjEOOX7hsBv&authuser=0


https://www.youtube.com/watch?v=sZ0z7B7QmjI&list=PLillGF-RfqbZ7s3t6ZInY3NjEOOX7hsBv&index=2&pp=iAQB

Summary

The video discusses the process of setting up a project to use ES6 (ES2015) features in a production environment. It explains the need for a transpiler like Babel to convert ES6 code into ES5 that can be run in older browsers. The video demonstrates how to install and configure Babel, create an initial ES6 file, and compile it into an ES5 version using the Babel CLI. This setup allows the developer to write modern JavaScript code while ensuring compatibility across a wide range of browsers.

Key Points

  • [0:00] Overview of the course covering ES6 (ES2015) features and the need to use a transpiler for production environments.
  • [0:42] Introducing Babel, a JavaScript compiler, and demonstrating its functionality through the online "Try it out" editor.
  • [2:07] Exploring the browser compatibility chart for ES6 features, highlighting the need for transpilation to ensure broad support.
  • [3:17] Instructions for setting up a project with Babel, including installing Node.js and Git Bash (optional).
  • [3:52] Walkthrough of the Babel CLI setup process, including creating a package.json file, installing Babel CLI and the ES2015 preset, and configuring the .babelrc file.
  • [7:54] Creating a source folder for ES6 code and a dist folder for the compiled ES5 output.
  • [8:35] Adding build scripts to the package.json file to automate the compilation process.
  • [9:47] Demonstrating the compilation of an ES6 class into its ES5 equivalent using the build script. https://www.youtube.com/watch?v=KWUcTt15fQs&list=PLillGF-RfqbZ7s3t6ZInY3NjEOOX7hsBv&index=3&pp=iAQB

Summary:

The video provides an in-depth look at the new variable declaration methods introduced in ECMAScript 6 (ES6), specifically the let and const keywords. It explains how these new declarations differ from the traditional var keyword, offering improved scoping and functionality. The video demonstrates the key differences between let and var through several code examples, showcasing how let introduces block-level scoping, unlike the global scoping of var. This allows for more predictable and intuitive variable behavior, addressing a common pain point for JavaScript developers. The video then introduces the const keyword, which creates constants that cannot be reassigned, and shows how it can be used to declare arrays that can be modified but not replaced entirely. Overall, the video covers the essential concepts and use cases for let and const, equipping viewers with a solid understanding of these powerful new tools in the ES6 ecosystem.

Key Points:

  • [0:00] Introduction to let and const, new variable declaration methods in ES6
  • [0:20] let provides block-level scope, unlike the global scope of var
  • [2:40] Example demonstrating how let behaves differently than var within a function
  • [5:10] let can be used in loops, maintaining block-level scope
  • [6:43] Introduction to const, which creates a constant variable
  • [6:58] const can be used to declare arrays that can be modified but not replaced

https://www.youtube.com/watch?v=RBLIm5LMrmc&list=PLillGF-RfqbZ7s3t6ZInY3NjEOOX7hsBv&index=4&pp=iAQB

Summary:

The video provides an introduction to ES6 classes in JavaScript. It demonstrates how to create a basic class called "User" with a constructor, properties, and methods. It then shows how to create an instance of the "User" class and call its methods. The video also covers static methods and how to create a subclass called "Member" that inherits from the "User" class, adding additional properties and methods.

Key Points:

  • [0:00] Introduction to ES6 classes in JavaScript
  • [0:25] Creating a "User" class with a constructor that takes in username, email, and password
  • [1:26] Adding a "register" method to the "User" class
  • [2:06] Instantiating a "User" object and calling the "register" method
  • [3:08] Creating a static "count_users" method in the "User" class
  • [4:23] Extending the "User" class to create a "Member" subclass
  • [4:48] Adding a "member_package" property to the "Member" class constructor
  • [5:42] Creating a "get_package" method in the "Member" class
  • [6:21] Instantiating a "Member" object and calling the "get_package" method
  • [7:05] Calling a method from the parent "User" class on the "Member" object https://www.youtube.com/watch?v=INPob8yPyBo&list=PLillGF-RfqbZ7s3t6ZInY3NjEOOX7hsBv&index=5&pp=iAQB

Summary:

This video explains template literals or template strings in ES6, which provide a more convenient way to work with strings in JavaScript. The speaker demonstrates how to create a simple template, insert it into an HTML element, and then shows how template literals allow for multi-line strings without the need for string concatenation. The video also covers how to embed variables and function calls within the template literals to dynamically generate content.

Key Points:

  • [0:00] Introduction to template literals in ES6
  • [0:10] Template literals provide an easy way to work with strings, especially for concatenation
  • [0:22] Creating a simple template literal with HTML elements
  • [0:57] Inserting the template literal into an HTML element
  • [1:57] Multiline template literals using backticks instead of quotes
  • [3:11] Embedding variables within template literals
  • [3:47] Embedding function calls within template literals to dynamically generate content
  • [4:44] Preview of upcoming video on new string methods in ES6 https://www.youtube.com/watch?v=XGG-OY8pJqA&list=PLillGF-RfqbZ7s3t6ZInY3NjEOOX7hsBv&index=6&pp=iAQB

Summary:

The video discusses several new string and number methods introduced in ES6 JavaScript. It covers the startsWith(), endsWith(), and includes() methods for strings, which allow you to check if a string starts with, ends with, or contains a specific substring. It also covers new numeric literals for hexadecimal, binary, and octal numbers, as well as the Number.isFinite(), Number.isNaN(), and Number.isInteger() methods for working with numbers.

Key Points:

  • [0:00] Introduction to new string and number methods in ES6
  • [0:12] Creating a string variable "hello my name is Brad and I love JavaScript"
  • [0:35] startsWith() method to check if a string starts with a specific substring
  • [1:36] endsWith() method to check if a string ends with a specific substring
  • [2:07] includes() method to check if a string contains a specific substring
  • [2:48] Introduction to new number methods
  • [2:55] Hexadecimal, binary, and octal number literals
  • [4:01] Number.isFinite() method to check if a number is finite
  • [4:50] Number.isNaN() method to check if a value is NaN
  • [5:16] Number.isInteger() method to check if a number is an integer

ES6 String Methods: startsWith(), endsWith(), and includes()

  • The startsWith() method checks if a string starts with a given substring.
  • The endsWith() method checks if a string ends with a given substring.
  • The includes() method checks if a string contains a given substring.
  • These methods provide a more efficient way to target specific expressions within a string, returning a boolean value.
  • These new string methods were introduced in ES6 to enhance functionality for working with strings in JavaScript.

ES6 Numeric Literals

  • ES6 introduced new numeric literal notations:
    • Hexadecimal: 0x
    • Binary: 0b
    • Octal: 0o
  • These new notations provide additional ways to represent numeric values in JavaScript code.
  • They help improve readability and maintainability when working with different number representations.
  • The new numeric literal notations are part of the ES6 language enhancements.

ES6 Number Methods: isFinite(), isNaN(), isInteger()

  • Number.isFinite() checks if a value is a finite number.
  • Number.isNaN() checks if a value is NaN (Not a Number).
  • Number.isInteger() checks if a value is an integer.
  • These new number methods in ES6 provide useful utilities for working with numbers in JavaScript.
  • They offer more precise checks compared to the global isFinite() and isNaN() functions in previous versions of JavaScript.

https://www.youtube.com/watch?v=Stne4zasR8M&list=PLillGF-RfqbZ7s3t6ZInY3NjEOOX7hsBv&index=7&pp=iAQB

Summary:

The video covers two new features introduced in ES6 (ECMAScript 6): default parameters and the spread operator. Default parameters allow for setting a default value if no parameter is provided, making the code more efficient compared to ES5. The spread operator (...) is used to expand an expression where multiple arguments are expected, eliminating the need for the apply() method in ES5. Both features make coding in ES6 simpler and cleaner.

Key Points:

  • [0:11] Introducing default parameters in ES6
  • [0:38] Default parameters provide a fallback value if no argument is passed
  • [1:12] Default parameters improve code efficiency compared to ES5
  • [2:01] Exploring the spread operator (...) in ES6
  • [2:22] The spread operator expands an expression where multiple arguments are expected
  • [3:08] The spread operator eliminates the need for the apply() method in ES5
  • [3:41] Both default parameters and the spread operator simplify and clean up code in ES6

ES6 Default Parameters

  • Default parameters in ES6 allow you to set a default value for a function parameter.
  • If no argument is provided for that parameter, the default value will be used.
  • This makes the code more efficient and concise compared to the workarounds in ES5.
  • Default parameters are a helpful language feature introduced in ES6 to improve JavaScript function handling.

ES6 Spread Operator

  • The spread operator, denoted by three dots (...), allows an expression to be expanded where multiple arguments are expected.
  • It simplifies passing arrays as arguments to a function, eliminating the need for the apply() method used in ES5.
  • The spread operator makes the code more readable and maintainable by reducing the complexity of function calls.
  • This feature, introduced in ES6, enhances the way developers work with function arguments in JavaScript. https://www.youtube.com/watch?v=ycohYSx5h9w&list=PLillGF-RfqbZ7s3t6ZInY3NjEOOX7hsBv&index=8&pp=iAQB

Summary:

In this video, the creator explains the concept of Set and Map objects in JavaScript. A Set is used to store unique values of any type, while a Map is a collection of key-value pairs. The video demonstrates how to create, add, delete, and retrieve data from both Set and Map, as well as the related concepts of WeakSet and WeakMap. The creator also highlights the advantages of using these data structures and how they can be used in conjunction with iterators.

Key Points:

  • [0:00] Introduction to Set and Map objects in JavaScript.
  • [0:05] Set object can store unique values of any type, including primitive values and object references.
  • [0:32] Creating a Set from an array, adding and deleting values, and checking the size of the Set.
  • [1:29] Adding different types of values to a Set, including objects.
  • [2:50] Iterating through the values in a Set using a forEach loop.
  • [4:12] Explanation of Map object, which stores key-value pairs.
  • [4:37] Creating a Map, adding and deleting key-value pairs, and checking the size of the Map.
  • [6:19] Introduction to WeakSet and WeakMap, which are related to objects.
  • [6:36] Creating a WeakSet and adding/deleting objects to it.
  • [9:08] Creating a WeakMap and adding/deleting key-value pairs.
  • [11:06] Conclusion and mention of using Set and Map with iterators in the next video.

Set vs WeakSet

Set

  • A Set is a collection of unique values of any type, whether primitive values or object references.
  • Sets maintain the insertion order of elements.
  • Sets support various methods for adding, deleting, and checking the existence of elements.
  • Sets are iterable, allowing you to loop through their elements.

WeakSet

  • A WeakSet is a collection that only stores objects, not primitive values.
  • The references to objects in a WeakSet are "weak", meaning they do not prevent the objects from being garbage collected.
  • WeakSets do not have a size property, and you cannot iterate over their elements.
  • WeakSets are primarily used to store temporary object references, helping to avoid memory leaks.

Map vs WeakMap

Map

  • A Map is a collection of key-value pairs, where both the keys and values can be of any type.
  • Maps maintain the insertion order of their elements.
  • Maps support various methods for adding, deleting, and accessing key-value pairs.
  • Maps are iterable, allowing you to loop through their entries.

WeakMap

  • A WeakMap is a collection of key-value pairs, where the keys must be objects, and the values can be arbitrary values (including objects).
  • The keys in a WeakMap are "weakly" held, meaning they do not prevent the objects from being garbage collected.
  • WeakMaps do not have a size property, and you cannot iterate over their elements.
  • WeakMaps are primarily used to store additional data associated with object keys without affecting the object's lifespan. Key Differences:
  1. Data Type: Sets and Maps can store any type of value, while WeakSets and WeakMaps can only store object references.
  2. Garbage Collection: WeakSets and WeakMaps allow for automatic garbage collection of their elements, unlike Sets and Maps.
  3. Iteration: Sets and Maps are iterable, allowing you to loop through their elements, while WeakSets and WeakMaps are not iterable.
  4. Size: Sets and Maps have a size property, while WeakSets and WeakMaps do not. The choice between using a Set/Map or a WeakSet/WeakMap depends on your specific use case. WeakSets and WeakMaps are useful when you need to store temporary object references and avoid memory leaks, while Sets and Maps are better suited for general-purpose collections that require iteration and access to the size of the collection. Sources:
    [1] Sets in JavaScript - GeeksforGeeks,
    https://www.geeksforgeeks.org/sets-in-javascript/
    [2] Applications of Set in JavaScript - GeeksforGeeks,
    https://www.geeksforgeeks.org/applications-of-set-in-javascript/
    [3] Set - JavaScript - MDN Web Docs - Mozilla,
    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set

https://www.youtube.com/watch?v=u4URamXstM0&list=PLillGF-RfqbZ7s3t6ZInY3NjEOOX7hsBv&index=9&pp=iAQB

Summary:

The video discusses the benefits of using ES6 arrow functions in JavaScript, which include a shorter syntax and the ability to bind the this keyword lexically. The presenter demonstrates how arrow functions can simplify the handling of this in a Prefixer class example, and also showcases the concise syntax of arrow functions compared to traditional function expressions.

Key Points:

  • [0:05] Arrow functions have two main benefits: shorter syntax and lexical binding of this.
  • [0:17] In the past, developers had to use workarounds like that or self to handle the this keyword in JavaScript.
  • [0:38] The presenter creates a Prefixer class with a prefix() method that uses the this keyword.
  • [1:08] Without arrow functions, the prefix() method needs to use a workaround like let that = this; to access the this.prefix property.
  • [3:07] Arrow functions allow the this keyword to be bound lexically, eliminating the need for the workaround.
  • [3:42] The presenter demonstrates a simple example of the syntax for an arrow function, converting a traditional function expression to an arrow function.
  • [4:50] The arrow function version of the add() function maintains the same functionality as the original function expression.

https://www.youtube.com/watch?v=XJEHuBZQ5dU&list=PLillGF-RfqbZ7s3t6ZInY3NjEOOX7hsBv&index=10&pp=iAQB

Summary:

This video provides an introduction to Promises in ES6 (ECMAScript 2015), which are used for deferred and asynchronous computations. The video demonstrates various examples of creating and using Promises, including immediately resolved Promises, Promises that resolve after a delay, and Promises that make AJAX requests to fetch data from a third-party API. The video covers key concepts such as the resolve and reject functions, the .then() and .catch() methods, and how to display the fetched data on a web page using template literals and DOM manipulation.

Key Points:

  • [0:00] Introduction to Promises in ES6
  • [0:21] Example of an immediately resolved Promise
  • [1:26] Example of a Promise that resolves after a delay using setTimeout()
  • [3:15] Example of using a Promise to fetch data from an API
  • [6:21] Using the JSONPlaceholder API to fetch to-do items
  • [8:27] Displaying the fetched data on a web page using template literals and DOM manipulation
  • [11:43] Summary of the ES6 features used in the video, including Promises, template strings, and the for...of loop
  • [11:59] Teaser for the next video on generators

https://www.youtube.com/watch?v=dcP039DYzmE&list=PLillGF-RfqbZ7s3t6ZInY3NjEOOX7hsBv&index=11&pp=iAQB

Summary:

This video provides an introduction to generators in ES6 JavaScript. Generators are special functions that can be paused and resumed, allowing them to yield values back to the caller. The video demonstrates how to create a generator, use the next() method to access the yielded values, and leverage generators as iterators within a for...of loop.

Key Points:

  • [0:07] Generators are functions that can be paused and resumed, yielding values at each pause.
  • [0:25] To create a generator, define a function with an asterisk after the function name.
  • [0:52] Inside the generator, use the yield keyword to specify values to be returned.
  • [1:35] To use a generator, assign it to a variable and call the next() method to access the yielded values.
  • [2:38] The next() method returns an object with two properties: value (the yielded value) and done (a Boolean indicating if the generator has completed).
  • [3:14] To signal the end of the generator, use the return keyword to return a final value.
  • [3:59] Generators can be used as iterators, allowing them to be used in for...of loops.

On this page