Web Tools #505 - Using bind(), React Tools, Testing, Uncats

Web Tools Weekly
WEB VERSION
Tools for Web Developers

Issue #505 • March 23, 2023

Advertisement

Developer Day: A Front-row Seat to What's New with Retool
Join our product and engineering leaders for a first look at what's new with Retool. We'll be diving deep into new GPT-powered features, Python support, and a brand-new way to rapidly deploy databases.

Developer Day with Retool

Register Now!

Most programming features are a little vague when they aren't accompanied by real-world use cases. Let's look at the JavaScript bind() method along with a few quick examples to make clear how practical it is.

As you might know, JavaScript's bind() method creates a new function with a bound this value and, optionally, bound arguments. The this value is the object that the function is bound to, and it determines what the this keyword refers to inside the function. If that sounds too vague and general, some examples will help.

A common use case for the bind() method is to set the this value of a function to a specific object. This can be useful when you have a function that needs to operate on a specific object, but you don't want to modify the function itself.

Here's a code example to make it clear:

const myPerson = {
  name: 'Jiminy',
  age: 29,
  msg() {
    console.log(`Hi, I'm ${this.name} and I'm ${this.age} years old.`);
  }
};

const otherPerson = {
  name: 'Demoine',
  age: 35
};

const boundMsg = myPerson.msg.bind(otherPerson);

// Log: "Hi, I'm Demoine and I'm 35 years old."
boundMsg();

In the above example, I have a myPerson object with a msg() method that logs to the console using the this keyword to refer to the object. I also have another object otherPerson with its own name and age.

I then create a function boundMsg by calling the bind() method on the msg() method of the myPerson object, and I pass in otherPerson as the this value. This means that when boundMsg() is called, the this keyword inside the function will refer to otherPerson instead of myPerson.

As you can see, it's pretty cool to be able to use bind() to create a new function that operates on a different object without modifying or creating a copy of the original function.

Another use case for bind() is to create a function with pre-set arguments. To illustrate:

function add(a, b) {
  return a + b;
}

const addTen = add.bind(null, 10);

console.log(addTen(16)); // 26
console.log(addTen(8)); // 18

In this example, I have a simple add() function that takes two arguments and returns the sum. I then create a new function called addTen() by calling bind() on add(). I use null as the this value and 10 as the first argument.

This means that when addTen() is called, it will always add 10 to the argument passed in to the new function. Again, no need to modify the original function or create a copy of it, using bind() makes this easier.

You can try both the above code examples in this CodePen.

Now on to this week's tools!
 

React Tools

Bright
A React server component for adding syntax highlighting to pages that adds nothing to your bundle size and uses all the themes from VS Code.

@react-hookz/web
A library of general-purpose React hooks built with care and SSR compatibility in mind.

Developer Day: A Front-row Seat to What's New with Retool
Join our product and engineering leaders for a first look at what's new with Retool. We'll be diving deep into new GPT-powered features, Python support, and a brand-new way to rapidly deploy databases.   SPONSORED  

React Pro Sidebar
A set of React components for creating high-level and customizable side navigation.

react-ansi-animation
React components for displaying ANSI art. It can render either HTML text elements or into a canvas and can also output text for Ink-based CLI applications.

react-ansi-animation

Evolu
A React Hooks library for local-first apps(opens in a new tab) with end-to-end encrypted backup and sync using SQLite(opens in a new tab) and CRDT.

react-curved-input
A small React component to turn any SVG path into a slider that the user can use to interactively animate an object across the shape of the SVG path.

Flexboard
A React component library for re-sizable sidebar panes, with options for draggability, min/max width, style, and more.

relay-nextjs
Relay Hooks integration for Next.js apps, designed for server rendering and uses React Suspense under the hood.

React Visual Grid
A React component to build image grids and masonry layouts, with good performance, support for different layouts, customizable thumbnail sizes, and more.

Conform
A progressive enhancement first form validation library for Remix and React Router.

On the Release Radar:

Testing and Debugging Tools

trace.cafe
If you've downloaded a performance profile (i.e. a "trace", usually a JSON file) from your browser's developer tools, you can sue this tool to upload and examine the trace with the performance panel visible like in DevTools.

WebPerformance Report
This is a unique idea. Get a personalized report via email every week on the status of a website that you want to monitor for web performance and web optimization, with Core Web Vitals included, powered by WebPageTest.

XSSHunter
Use Docker and Dockery Compose to test and find blind cross-site scripting vulnerabilities.

Don’t Just Read The News—Make The News
Looking for an edge in business? Look no further than The Information. Their team of award-winning journalists provide exclusive insights into tech and finance, with original reporting, big interviews, and more that you won’t find anywhere else. Subscribe now and save 25%.   SPONSORED  

precloud
An open-source CLI that runs checks on infrastructure-as-code to catch potential deployment issues before deploying.

Rayst
Chrome extension that displays a side panel showing stats and technologies associated with any web page you're visiting.

Rayst

tslog
A beautiful logging experience for TypeScript and JavaScript, for powerful, fast, and expressive logging.

swr-devtools
A developer tool for SWR, the React hooks library for data fetching, with support for SWR v1 or later.

tinybench
A simple and lightweight 7KB (2KB minified/gzip'd) benchmarking library that uses Web APIs (i.e. process.hrtime or performance.now) to run your code benchmarks in multiple JavaScript runtimes.

Carbon Neutral Website
A carbon emission calculator that takes into account the power consumption of device and server during browsing a web page.

spall
A profiler library and a web front end for exploring your code and digging into potential performance problems.

The Uncategorizables

Node.js Toolbox
Find actively maintained and popular libraries in the Node.js ecosystem, filterable by category.

Passwordless
API that makes passkeys and web authentication easy. Currently free while in Beta.

Eraser
A whiteboard for engineering teams that offers unlimited collaborators and up to 5 workspaces in the free plan.

filebrowser
A Go-based file managing interface within a specified directory that can be used to upload, delete, preview, rename, and edit your files.

CronTool
A free tool to debug, edit, learn and view crontab/cron expressions, no registration required.

Ai Tool Hunt
A searchable and categorized directory of 1400+ AI-based tools to help you discover the latest in AI apps and services.

Ai Tool Hunt

Lotus
An open-source tool to optimize, test, and deploy usage-based, per-seat, or enterprise pricing and packaging models in minutes, to unlock the true value of your SaaS product.

Ask No Code
A Stack Overflow-like community where you can ask and answer questions related to no-code tools and processes.

Don’t Just Read The News—Make The News
Looking for an edge in business? Look no further than The Information. Their team of award-winning journalists provide exclusive insights into tech and finance, with original reporting, big interviews, and more that you won’t find anywhere else. Subscribe now and save 25%.   SPONSORED  

AXplorer
A "use-to-earn", private, fast and secure web browser with a free built-in VPN that includes an embedded crypto wallet.

OG Image Playground
A playground for experimenting and testing out social media image generation via the Open Graph Protocol and Vercel's og library.

Fragment Mono
A monospaced coding version of the classic Helvetica font, created by modifying and extending another font called Nimbus Sans.

Commercial Apps and Classifieds

These are commercial apps, affiliate links, PPC ads, and paid classifieds. Submit yours!
Microns – Marketplace to buy and sell startups with no commission, just a yearly fee.
JS E-Books Bundle – All my JS and DOM scripting tips bundled into an affordable e-books package.    AD
Bugpilot – A bug reporting tool for SaaS apps and integrates with a number of other tools and services.
axiom.ai – Use browser bots to automate website actions and repetitive tasks on any website or web app.
Tech Brew – A 3-times-a-week newsletter with the latest tech news impacting you and your future. AD
SuperDev – A No-code plug n’ play
DevOps platform for engineering teams and startups.
Scribo – Create landing pages and complex web apps using a low/no-code platform.

A Tweet for Thought

An interesting thread from Lea Verou (with some further discussion on Mastodon) that puts forth the idea that the main purpose of Web Components has gone largely unrealized.
 
A Tweet for Thought
 

Send Me Your Tools!

Made something? Send links via Direct Message on Twitter @WebToolsWeekly (details here). No tutorials or articles, please. If you have any suggestions for improvement or corrections, feel free to reply to this email.
 

Before I Go...

Is it cut short? is a website where you can find out if a TV show that was cancelled ended with a cliffhanger. Might help to decide if you want to start watching a series. But note that it only includes shows that were actually cut short, which makes sense. So if something isn't listed, then it's safe to watch without worrying that it ended and didn't resolve a main plotline.

Thanks to everyone for subscribing and reading!

Keep tooling,
Louis
@WebToolsWeekly
PayPal.me/WebToolsWeekly

Key phrases

Older messages

Web Tools #504 - AbortController, Frameworks, Build Tools, JS Utils

Thursday, March 16, 2023

Web Tools Weekly WEB VERSION Issue #504 • March 16, 2023 Advertisement CodiumAI. Generating Meaningful Tests for Busy Devs. With CodiumAI, you get non-trivial tests (and trivial, too!) suggested right

Web Tools #503 - Factory Pattern, CSS Tools, Git/CLI, Uncats

Thursday, March 9, 2023

Web Tools Weekly WEB VERSION Issue #503 • March 9, 2023 Advertisement Sharpen your Math, Data, and Computer Science Skills Whether you're a professional looking for an edge in your career or a

Web Tools #502 - Promises, Media/SVG, Build Tools, React

Thursday, March 2, 2023

Web Tools Weekly WEB VERSION Issue #502 • March 2, 2023 Advertisement Sharpen your Math, Data, and Computer Science Skills Whether you're a professional looking for an edge in your career or a

Web Tools #501 - FontFaceSet, JS Libraries, Databases, Jamstack

Thursday, February 23, 2023

Web Tools Weekly WEB VERSION Issue #501 • February 23, 2023 Advertisement Build Internal Tools, Remarkably Fast If you or your team are spending more time on boilerplate code and other redundant work

Web Tools #500 - assert(), Frameworks, JS Utils, Uncats

Friday, February 17, 2023

Web Tools Weekly WEB VERSION Issue #500 • February 16, 2023 Advertisement The New Tab Page You'll Actually Use Ah, the hyperlink. It's the single coolest thing on the web. There wouldn't

You Might Also Like

Berliner Goes Tabloid 🤬

Thursday, April 18, 2024

The movie that perfectly explains what that NPR editor did. Here's a version for your browser. Hunting for the end of the long tail • April 17, 2024 Berliner Goes Tabloid Considering the tale of

Tuesday Triage #196

Wednesday, April 17, 2024

Your weekly crème de la crème of the Internet is here! The 196th edition featuring Naismith's rule, cow magnet, and Little Sparta. ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌

Atlas humanoid robot goes electric 

Wednesday, April 17, 2024

Meta goes back to the drawing board and Tesla does some advertising View this email online in your browser By Christine Hall Wednesday, April 17, 2024 Good afternoon, and welcome to your Hump Day

📞 1990s Technology We Still Use Today — How to Fix Google Maps When It's Not Working

Wednesday, April 17, 2024

Also: Why You Should Buy Last Year's Flagship TV, and More! How-To Geek Logo April 17, 2024 📩 Get expert reviews, the hottest deals, how-to's, breaking news, and more delivered directly to your

Today only: Join Incubator to get these bonuses

Wednesday, April 17, 2024

I'll work with you personally in a small group ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌

JSK Daily for Apr 17, 2024

Wednesday, April 17, 2024

JSK Daily for Apr 17, 2024 View this email in your browser A community curated daily e-mail of JavaScript news React useState Vs. Context API: When to Use Them React has improved its state management

Daily Coding Problem: Problem #1415 [Easy]

Wednesday, April 17, 2024

Daily Coding Problem Good morning! Here's your coding interview problem for today. This problem was asked by Stripe. Write a function to flatten a nested dictionary. Namespace the keys with a

⚙️ Workplace AI

Wednesday, April 17, 2024

Plus: Amazon Music just copy pasted Spotify ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌

Charted | The World's Biggest Nuclear Energy Producers ⚡

Wednesday, April 17, 2024

China has grown its nuclear capacity over the last decade, now ranking second on the list of top nuclear energy producers. View Online | Subscribe Presented by: FEATURED STORY The World's Biggest

You’re invited: 2024 Security report insights webinar

Wednesday, April 17, 2024

Join us April 25th. ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏