- Prerequisites
- System Requirements
- Initial Setup
- Install Dependencies
- Available Commands
- Running Scripts
- Development Commands
- Troubleshooting
- Extending the Application
- Best Practices
- Documentation
- External Resources
- Version
- Last Updated
- Node.js: Version 16.13.1 or higher
- Package Manager: npm (comes with Node.js)
- Operating System: Any OS that supports Node.js (Windows, macOS, Linux)
- Memory: 512MB RAM minimum (sufficient for running examples)
- Basic understanding of JavaScript
- Familiarity with command line/terminal
git clone https://github.com/orassayag/es2021.git
cd es2021Since this project has no external dependencies, this step is optional but good practice:
npm installCheck Node.js version:
node --versionShould show v16.13.1 or higher.
npm startRun All Examples:
npm startTest Command (placeholder):
npm test- Open the project in your IDE (VSCode recommended)
- Install dependencies:
npm install
- Verify Node.js version (16.13.1 or higher):
node --version
Execute all ES2021 feature demonstrations:
npm startThis will run through all the examples in index.js and display the output in your console.
Makes large numbers more readable by using underscores as visual separators.
Example:
let billion = 1_000_000_000;
let price = 1_475_938.38;Replace all occurrences of a substring without using regular expressions.
Old way:
message.replace(/\+/g, ' ');New way:
message.replaceAll('+', ' ');Three new operators that combine logical operations with assignment:
- &&= (AND assignment): Assigns only if the left side is truthy
- ||= (OR assignment): Assigns only if the left side is falsy
- ??= (Nullish coalescing assignment): Assigns only if the left side is null or undefined
Returns as soon as any of the promises fulfills. Rejects only if all promises reject.
Use case: When you need the first successful result from multiple sources.
Define truly private methods using the # prefix that cannot be accessed outside the class.
class Example {
#privateMethod() {}
publicMethod() {}
}Create private accessors for class properties.
class Example {
get #privateProp() {}
set #privateProp(value) {}
}Create weak references to objects that don't prevent garbage collection.
Use case: Caching scenarios where you want objects to be collected if memory is needed.
Execute cleanup logic when objects are garbage collected.
Use case: Release resources, close connections, or perform cleanup when objects are no longer needed.
The index.js file contains:
- Clearly marked sections for each feature
- Working examples with console output
- Comments explaining the old vs new approaches
- Edge cases and special behaviors
To experiment with the features:
- Open
index.js - Modify the example code
- Run
npm startto see your changes - Observe the console output
ES2021 features are supported in:
- Node.js 16+ (all features)
- Chrome 90+
- Firefox 88+
- Safari 14.1+
- Edge 90+
For older environments, consider using Babel transpilation.
- All examples are self-contained and can be run independently
- The code demonstrates practical use cases, not just syntax
- Some features (WeakRef, FinalizationRegistry) are advanced and should be used carefully
- Private class fields and methods provide true encapsulation, unlike naming conventions
Problem: "SyntaxError: Unexpected token" or similar errors
Solutions:
- Check your Node.js version:
node --version
- Ensure you have Node.js 16.13.1 or higher installed
- Download the latest LTS version from nodejs.org
Problem: "Error: Cannot find module"
Solutions:
- Ensure you're in the correct project directory
- Run
npm install(even though there are no dependencies) - Check that
index.jsexists in the project root
Problem: "EACCES: permission denied"
Solutions:
- Ensure you have read/write permissions for the project directory
- Avoid using
sudounless necessary - On Windows, run Command Prompt or PowerShell as Administrator if needed
To add more ES2021 examples or extend existing ones:
- Open
index.js - Add your code in the appropriate section or create a new section
- Follow the existing code style and commenting patterns
- Run
npm startto verify your changes work
All code is in index.js for simplicity. If the project grows, you could:
- Split examples into separate files
- Add a build system
- Add testing framework
- Read Carefully: Take time to understand each example
- Experiment: Modify the code to see different outcomes
- Take Notes: Write down what you learn
- Apply: Try using the features in your own projects
- Review: Come back later to reinforce your knowledge
- Follow the Style: Use Prettier for consistent formatting
- Add Comments: Explain what your code does
- Keep It Simple: Focus on one concept per example
- Test Changes: Always run
npm startafter making changes
- README.md - Project overview and features
- CONTRIBUTING.md - Contribution guidelines
- CODE_OF_CONDUCT.md - Code of conduct
- SECURITY.md - Security policy
- CHANGELOG.md - Change history
- ECMAScript 2021 Specification
- MDN Web Docs - JavaScript
- Original Blog Post Inspiration
- Node.js Documentation
Version: 1.0.0
Last Updated: June 2026
- Or Assayag - Initial work - orassayag
- Or Assayag orassayag@gmail.com
- GitHub: https://github.com/orassayag
- StackOverflow: https://stackoverflow.com/users/4442606/or-assayag?tab=profile
- LinkedIn: https://linkedin.com/in/orassayag