3 ms·
JavaScript’s Backtick Strings Are Likely the Wrong Tool for Your Job
- junon 3y agoThis article is just "string concatenation bad, automatic machinery for URL encoding good", just with the extra zest of blaming template literals (the true name for "backtick strings"). This is something we learned 30 years ago with SQL injection. In reality, template literals aren't the problem. In fact, it'd be trivial to write a tagged template literal function that auto-encoded all parameters you passed to it anyway - I'm sure one already exists in package form somewhere. This is a red herring. Template literals aren't your issue.
- cwdegidio 3y agoBasic interface design. If you require data to be in a specific format, then only give the user those options as input. The country code example is easily solved with a select field whose values are proper ISO country designations. This article just reads like the usual “think of something controversial to say and blog about it.”