DEV Community

Discussion on: Mastering Javascript One-Liners to Look Like a Pro

Collapse
 
mrlinxed profile image
Mr. Linxed • Edited

Remember that one-liners are not always better/faster/easier.

Readability goes over being clever.

Especially when a one-liner only passes its parameters to another method like this one

const copyToClipboard = (content) => navigator.clipboard.writeText(content);
Enter fullscreen mode Exit fullscreen mode

What's wrong with just:

navigator.clipboard.writeText(content);
Enter fullscreen mode Exit fullscreen mode

If anything, the copyToClipboard should check if the clipboard API is available to use.