• Weekly coding tricks (each Tuesday) • Daily Software Engineer thoughts & quick tips • Developing an app to create your own code snippets!

Check here 👉
Joined July 2024
quicktricks.dev retweeted
C# Tip! 🚀 Use the required keyword for properties that MUST be initialized when creating an object. It guarantees crucial data is never missing, making your code safer and preventing runtime errors.
3
1
4
228
quicktricks.dev retweeted
🔥 JavaScript Tip! Say goodbye to loops when transforming arrays to a single value. Use Array.reduce and do it with ease!
1
2
4
246
quicktricks.dev retweeted
C# tip! 💥 Embrace init-only setters to build immutable objects. Set properties only during object creation, ensuring data integrity and preventing unwanted modifications after initialization.
1
1
4
195
Tired of duplicate array elements in JavaScript? 😫 Use Set() and the spread operator ... for the cleanest possible solution to create an array with unique elements!
1
3
187
Stop using string concatenation to handle query params in JavaScript! 👉Use the URLSearchParams interface and its methods to easily manipulate query params. Forget about manual parsing errors and encoding issues!
2
1
4
1,749
Discover CSS's :has() pseudo-class! 🚀 A true "parent selector" that lets you style elements based on their descendants. You can style a .card only if it contains a button! Powerful conditional CSS.
3
1
5
1,768
Tired of manual array formatting when displaying it to user? 😮‍💨 Use JavaScript's Intl.ListFormat instead! It handles locale-specific formatting (e.g., 'A, B, and C' vs 'A, B y C') in a simple and elegant way.
1
1
2
330
Stop using JSON.parse(JSON.stringify()) for deep copies! 🚫 Replace it with JavaScript's structuredClone()! It can copy objects and other complex types like Maps, and RegEx. It also clones functions and handles circular references. All that in a single, elegant line of code. 🎩
1
1
6
571
Promise.allSettled() lets you wait for ALL your promises to complete. Doesn't matter if they succeed or fail. You can get individual results (fulfilled/rejected) for each promise. Perfect for parallel async operations where you need every outcome at the end.
1
1
329
Having a long list of elements that can be identified by a key? Need to retrieve an element fast? Map object can help you with that in JavaScript. It is a collection of key-value pairs. A key in the Map must be unique. See the details how to create a Map in the today's trick!
1
1
3
487
Ever wondered how to swap two variables in JavaScript without needing a temporary variable? Array destructuring comes to the rescue! This modern JavaScript feature lets you assign variables from arrays or objects. Check the example in today's trick snippet!
2
1
4
986
Ever wondered the difference between "as" and "satisfies" in TypeScript?🤔 One preserves your original type, the other narrows it down. One cast the type without verifying it. The other validates and throws an error if the type is not satisfied. Today’s tip breaks it down.
3
2
7
897
👉JavaScript object immutability options In JavaScript, by default, you can modify the objects you create. However, sometimes, you may want to ensure the object remains the same once created. There are three built-in methods that can help you with that.
2
1
1
3
566
✨ #JavaScript trick! Tagged Template Literals allows you to parse template literals with a function. When the tag function is called (highlight in this example), it receives an array of static string parts and also the values of each interpolated expression. You can use them and transform the literal however you want. You don't event have to return the string back from the function.
1
1
368
✨#JavaScript trick! Did you know that you have at least three ways to truncate numbers to integers in JavaScript? They are "Math.trunc", "parseInt" and the most surprising one: "~~". That's right, you can use bitwise NOT operator twice to truncate a number!
2
1
6
811
🚀 Master Utility Types in TypeScript! TypeScript's utility types help streamline type definitions, making them concise, reusable, and expressive. They can enhance type safety and reduce boilerplate in your code! Below you can find overview of the most popular ones. 🧵👇👇👇 ➡️ Partial — Make everything optional! Convert all properties in T to optional. ➡️ Pick — Select only what you need! Extract specific properties K from T. ➡️ Omit — Exclude unwanted fields! Remove certain properties K from T. ➡️ Required — Ensure completeness! Convert all properties in T to required. ➡️ Readonly — Lock down your data! Prevent mutations by making all properties read-only. ➡️ Record — Define structured objects! Create a type with keys K mapped to values of type T.
2
2
11
419
quicktricks.dev retweeted
My first trick/tip in @quicktricks_dev @e_opore you should add some of your great tips here :D quicktricks.dev/trick/f06bd2…
1
1
5
614