18 min read JavaScript, API, Coding Share on Twitter, LinkedIn The way JavaScript handles time has evolved significantly, from the built-in Date API to Moment.js and now Temporal. The new standard fills gaps in the original Date API while addressing limitations found in Moment and other libraries. Joe Attardi shares practical “recipes” for migrating Moment-based code to the new Temporal API. Almost any kind of application written in JavaScript works with times or dates in some capacity.
Is this you? As a journalist, you can create a free Muck Rack account to customize your profile, list your contact preferences, and upload a portfolio of your best work.
Claim your profile
Articles by Joe Attardi
How and when to use JavaScript arrow functions
The ES2015 standard introduced arrow functions to JavaScript. Arrow functions have a simpler syntax than standard functions, but we’ll also see that there are some important differences in how they behave. What are JavaScript arrow functions? Arrow functions can be used almost anywhere a standard function expression can be used, with a few exceptions. They have a compact syntax, and like standard functions, have an argument list, a body, and a possible return value.
How to Programmatically Highlight Text with the CSS Custom Highlight API
You can highlight text in the browser by clicking and dragging through the desired text. And sometimes this works fine. But there are times when you’ll want to programmatically highlight some text in an HTML document. In this article, I’ll discuss a couple ways you can do this. The first is using the <mark> element, and the second is using the CSS Custom Highlight API. We’ll go through examples, and I’ll explain the issues with <mark>.
Beyond breakpoints: Leveraging user preference media queries in CSS
If you build web sites or apps, chances are you work with media queries. These handy CSS tools allow you to adjust your layout depending on the size of the device. They are a key part of responsive design. You can query based on the width of the device, its aspect ratio, orientation, and more. These all allow you to fine-tune your layout for the device being used.
Using git bisect, the detective tool for debugging
Youre working on a bug fix and find some bad code that causes a bug. The git blame command will tell you who the last developer was that modified that line, and when they modified it. But what if you dont know what code introduced the bug? For these situations, the git bisect command can help. To use git bisect, youll need to find a commit where the bug exists (a bad commit), and youll also need to find an older commit where the bug doesnt exist (a good commit).
Patterns for efficient DOM manipulation with vanilla JavaScript
These days, frameworks are all the rage. But sometimes we still turn to DOM manipulation with vanilla JavaScript. The typical pattern for DOM manipulation using vanilla JavaScript is something like this: first, you need to get a reference to the DOM element you want to work with. This is often done with functions like getElementById or querySelector.
How JavaScript Promises Work - Handbook for Beginners
Many operations, such as network requests, are asynchronous in nature. One of the most useful and powerful tools for working with asynchronous code is the Promise. In this handbook, you'll learn all about JavaScript Promises and how to use them. Table of Contents What is a Promise? How to Create a Promise Promise Chaining Promise Anti-Patterns Summary What is a Promise? Let's begin by looking at what a Promise is. In simple terms, a Promise is an object representing an asynchronous operation.
How to Center Text Vertically with CSS
If you have some text inside a div, and nothing else, the div's height will match the text height. Suppose, though, you have some text and an image. Your text will be aligned at the bottom of the div, which is usually not what you want. In this article, you'll learn a couple of ways to vertically center your text inside such a div or other element.
How to Build Your First Web Component
In 2023, browser support for web components (also known as custom elements) is really good. There's never been a better time to start building your own custom elements. Web components, also known as custom elements, are new HTML elements that you create. These elements encapsulate some markup, style, and interactivity. In this article, you'll learn the basics of web components and create a very simple web component that shows the current date.
Web Browser API Cookbook
by Publisher(s): O'Reilly Media, Inc. ISBN: 9781098150631 Read it now on the O’Reilly learning platform with a 10-day free trial. O’Reilly members get unlimited access to books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers. JavaScript gives web developers great power to create rich interactive browser experiences, and much of that power is provided by the browser itself.
Show More
loading
Actions
Is this you?
As a journalist, you can create a free Muck Rack account to customize your profile, list your contact preferences, and upload a portfolio of your best work.Get in touch with Joe
Contact Joe, search articles and posts on X, monitor coverage, and track replies from one place.
Learn more about Muck Rack