Angular Stream
55 subscribers
21 photos
271 links
Angular news, events, videos etc.
If you want to recommend a post please write @hobbyts911
Download Telegram
🚨 Stop Splitting URLs in #JavaScript the Wrong Way! 🚨

We’ve all been there: You need to work with a URL string, and your first instinct is to use String.split(). Maybe you ended up juggling multiple temporary variables, awkwardly handling query parameters with extra splits and joins, and producing buggy, hard-to-maintain code. 😖 There must be a better way, right? 🤔

Enter the Native URL Constructor

The URL constructor in JavaScript is a game changer! It parses a URL for you and gives you back a structured, easy-to-use object that contains everything you need.

👀 Why Use URL?

Clean and Intuitive: Easy to understand and maintain.

Built-In Validation: Automatically validates and formats your URLs.

Feature-Rich: Handles all parts of the URL (host, protocol, path, query, fragment).

Performance Boost: Native support means less overhead compared to custom string operations.

No more manual string manipulation. Just clean, readable, and bug-free code! 🚀
🔥1
Don't miss to ready those articles of this new Angular Dev Team contributor.
For info - Matthieu invented Angular Hydration debugging tool.
https://riegler.fr/blog
Did you know that in angular version 19+ you can use

#name
instead of
private name
to make them true private?

I didn't know that properties with private field works only before compile time and it is open in production code for access.
Here is a good article about this https://riegler.fr/blog/2024-05-17-private-fields-downleveling

Make sure you are not using in earlier angular versions as it will result in weakMap creation.

#angular #ts #typescript #advanced #tips