Q&A
Mastering Modern JavaScript
JavaScript could be the most widely used programming language in the world, but for many developers, its modern version looks very different from what they first learned. With the advent of ECMAScript 6 (ES6) and continued evolution of the JavaScript ecosystem, new features like classes, async/await, and modern collection handling techniques are reshaping the way developers build applications.
That's exactly why veteran developer and educator Paul Sheriff is leading a hands-on workshop at the upcoming VSLive! Developer Training Seminar, Master Modern JavaScript: Unlock the Full Potential of Your Code. Taking place June 2-4, the three-day event offers developers a deep dive into the latest capabilities of JavaScript, with practical insights designed to boost productivity and reduce boilerplate code.
JavaScript has come a long way, says Sheriff, a long-time consultant and mentor. He notes that features like block-scoped variables, improved asynchronous patterns, and powerful templating options are making JavaScript applications faster to build and easier to maintain.
Topics covered in the workshop span a wide range of modern JavaScript capabilities, including built-in methods for streamlining code, robust exception handling, variable scope and hoisting, ES6 class-based object-oriented programming, dynamic HTML templating, asynchronous programming with async/await, building and testing Node.js web API servers, using the Fetch API for data handling, and deploying full Node.js-powered websites.
Whether you're moving from .NET to JavaScript, updating legacy codebases, or just looking to sharpen your front-end skills, this seminar promises a fresh look at how modern JavaScript can level up your development game, Sheriff said. Ahead of the event, we caught up with him to learn more about the key features he'll be covering, why they matter, how developers can apply them right away and how they can prepare for the seminar.
VisualStudioMagazine: What inspired you to present a seminar on this topic?
Sheriff: I have been moving some projects from .NET to JavaScript recently and have found so many new features in JavaScript that I did not know were available.
"These new features have allowed me to create JavaScript applications much quicker than before and with much less code. I want to share that information with others in the JavaScript community."
Paul Sheriff, Consultant, Teacher and Mentor
These new features have allowed me to create JavaScript applications much quicker than before and with much less code. I want to share that information with others in the JavaScript community.
What are some of the most impactful recent JavaScript features that developers should start using today?
There are two main areas that I think have really been instrumental in my applications. First is the use of the class keyword and the object-oriented features of JavaScript. You can now create classes with public and private methods and properties and take advantage of inheritance just like in other object-oriented languages. Secondly, is the many different methods and techniques for collection handling. Using the new methods on arrays can really cut down the amount of code for standard processes such as mapping new objects, aggregating data, finding the difference and intersections of two arrays, filtering data from arrays, and much more.
How does the use of let, const, and var influence variable scope, and what are the best practices for choosing between them?
The var keyword is all but obsolete with the introduction of let and const. You have true block-level scope with let and const that is not possible with var. Using these keywords should help to not pollute the global scope of your applications. I use let for almost everything, unless I truly have a value that never changes, in which case, I use the const keyword.
What are the key advantages of using ES6 classes over traditional JavaScript constructor functions?
The use of JavaScript constructor functions really confused programmers just being introduced to JavaScript. The syntax was just not very intuitive. The class keyword makes it very easy to see what is encapsulated within the scope of a class.
How does async/await improve asynchronous programming compared to traditional callback functions?
The async/await keywords allow programmers to see the program flow much easier. When using callbacks, it was very hard to distinguish where one function started and another one ended. When using async/await you avoid callback nesting which makes your code very hard to read. You get all the benefits of asynchronous programming with async/await, but your logic looks like synchronous code. This makes it easier to read code that was written by someone else and is easier to code this logic yourself.
What are some best practices for handling API requests using the Fetch API?
The Fetch API fetch() function is promise-based unlike the old XMLHttpRequest object. Fetch provides better flexibility in headers and request bodies. The error handling with fetch() is handled with a catch() method just like all promise-based technologies. This makes it more consistent with other promise-based APIs you may use. The Fetch API is also fully supported in Node.js while the XMLHttpRequest object is not.
How does using templating engines like Handlebars.js simplify dynamic HTML rendering in JavaScript applications?
I like using a templating engine because it keeps my HTML markup separate from my JavaScript code. I can put my HTML into a <template> element and in doing so, I can use my editors' IntelliSense features to help me structure my HTML tags. If you are placing HTML tags into a string, you get no help which can lead to errors at runtime. Many times, I can reuse the HTML templates across various pages which makes maintenance easier. Making changes to the layout can be made in the template by a designer, while the JavaScript code does not necessarily have to change.
Note: Those wishing to attend the seminar can save money by registering early, according to the event's pricing page. "Save $150 when you register by the May 9 Early Bird deadline," said the organizer of the seminar, which is presented by the parent company of Visual Studio Magazine.
About the Author
David Ramel is an editor and writer at Converge 360.