Build complex string types using dynamic expressions within backticks.
type Endpoint = `/users/${number}`;
const validEndpoint: Endpoint = '/users/123';
// const invalidEndpoint: Endpoint = '/posts/456'; // Error: Type '"/posts/456"' is not assignable to type 'Endpoint'
representing API responses, URL patterns, or validation formats.
➖➖➖➖➖➖
#TypeScript
Please open Telegram to view this post
VIEW IN TELEGRAM
👍7❤3
num?const num = parseInt('7*6', 10);For example, in "78", only "7" is valid, so it parses it into the decimal 7, ignoring the "" and "8". Thus, num now equals 7.
➖➖➖➖➖➖
#JavaScript #Quiz
Please open Telegram to view this post
VIEW IN TELEGRAM
👍8🤯5
import { useState } from 'react';
function Counter() {
const [count, setCount] = useState(0);
return (
<div>
<p>You clicked {count} times</p>
<button onClick={() => setCount(count + 1)}>Click me</button>
</div>
);
}import { useRef } from 'react';
function InputFocus() {
const inputRef = useRef(null);
function handleFocus() {
inputRef.current.focus();
}
return (
<div>
<input ref={inputRef} />
<button onClick={handleFocus}>Focus Input</button>
</div>
);
}- State is immutable
- Avoid reading/writing refs during rendering
- Both persist data and have different update behaviors
➖➖➖➖➖➖
➖➖➖➖➖➖
#JavaScript #ReactJS
Please open Telegram to view this post
VIEW IN TELEGRAM
👍11😎1
Utilize functions that take and return types, enabling powerful abstractions like generic type predicates and type builders.
type IsStringLiteral<T> = T extends string ? true : false;
function logIfString<T>(value: T): T extends string ? void : T {
if (IsStringLiteral<T>) {
console.log(value);
}
return value;
}
Creating dynamic component that have multiple states and behaviors.
➖➖➖➖➖➖
#TypeScript
Please open Telegram to view this post
VIEW IN TELEGRAM
👍6❤3
const user = {
email: "mail@hmouasvi.dev",
updateEmail: email => {
this.email = email;
}
}
user.updateEmail("new@hmousavi.dev")
console.log(user.email)mail@hmousavi.devnew@hmousavi.dev➖➖➖➖➖➖
#JavaScript #Quiz
Please open Telegram to view this post
VIEW IN TELEGRAM
👍9🤯5❤4
✨ Software Engineering Quote
💬 Programs must be written with the idea that they will be read by people, and only incidentally for machines to execute.
🔣 Harold Abelson
➖➖➖➖➖➖
#Agile #softwareEngineering
🖥 Follow @devDastan for more content.
➖➖➖➖➖➖
#Agile #softwareEngineering
Please open Telegram to view this post
VIEW IN TELEGRAM
❤9👍5
/* Child combinator: selects direct children of an element */
.parent > .child {
color: red;
}
.faq-item:nth-of-type(odd) .faq-question{
background-color: #fff; /* For odd items
*/
} .faq-item:first-of-type .faq-question {
border-top: 2px solid #007BFF;
}:first-letter, ::first-line):/* ::after used to display "+" symbol */
.faq-question::after {
content: '+';
color: #00ad8f;
font-size: 1.4em;
}
.faq-item[data-category^="important"] .faq-question {
color: #E91E63;
}➖➖➖➖➖➖
➖➖➖➖➖➖
#css
Please open Telegram to view this post
VIEW IN TELEGRAM
👍6🤯3❤2😎1
Shape types based on conditions, creating dynamic type hierarchies. For example, defining a type that’s an
object with specific properties depending on a provided string value.
type Config = {
type: 'basic' | 'advanced';
};
type BasicConfig = Config & { type: 'basic' };
type AdvancedConfig = Config & { type: 'advanced' };
function configure(config: Config): void {
if (config.type === 'basic') {
console.log('Applying basic configuration');
} else {
console.log('Applying advanced configuration');
}
}Useful for strategy patterns and implementing high-level business logic.
➖➖➖➖➖➖
#TypeScript
Please open Telegram to view this post
VIEW IN TELEGRAM
👍8❤5🤯2😎1
🔸 Involve all stakeholders in mapping security risks and protections.
🔸 Develop a strong security culture affecting daily procedures and offerings.
🔸 Validate incoming data at each application stage.
🔸 Use libraries like dom-purify for quicker security implementation.
🔸 Refer to OWASP cheat sheet series for input/output sanitization.
🔸 Use Software Composition Analysis (SCA) for third-party library security.
🔸 Implement Content-Security-Policy (CSP) for front-end security.
We will learn more about the tools we can use to check our website's security!
➖➖➖➖➖➖
➖➖➖➖➖➖
#network #security
Please open Telegram to view this post
VIEW IN TELEGRAM
👍11❤3
➖➖➖➖➖➖
➖➖➖➖➖➖
#softwareEngineering #softSkill
Please open Telegram to view this post
VIEW IN TELEGRAM
👍11❤2😎1
✨ Software Engineering Quote
💬 Code is like humor. When you have to explain it, it’s bad.
🔣 Cory House
➖➖➖➖➖➖
#softwareEngineering #programming
🖥 Follow @devDastan for more content.
➖➖➖➖➖➖
#softwareEngineering #programming
Please open Telegram to view this post
VIEW IN TELEGRAM
👍12🤯1🍌1
🔺 Code Review Pyramid
❤ Read Previous Parts: [Code Review Best Practices]
🗣️ Each layer of Code Review Pyramid is a characteristic to which the reviewed code must conform.
The bottom layer is the correctness of the code, which is of prime importance.
1️⃣ Code Style
🟢 Consistent naming and formatting.
🔘 Avoid duplication and unused imports.
🟢 Use automatic code formatting tools.
2️⃣ Tests
🟢 Review test cases for coverage.
🔘 Automate testing using plugins.
3️⃣ Documentation
🟢 Keep documentation comprehensive and up-to-date.
4️⃣ Implementation Semantics
🟢 Ensure code meets requirements, is efficient, and secure.
🔘 Check for error handling, resource management, concurrency, and third-party libraries.
🟢 Avoid code smells and anti-patterns.
5️⃣ API Semantics
🟢 Ensure API design follows best practices and provides a clear interface.
🔘 Check for consistency, versioning, error messages, pagination, filtering, and performance.
🟢 Ensure no internal logic leakage, no breaking of existing API, and proper authentication/authorization.
⚠️ Code review shouldn’t proceed to upper layers until the bottom layer, correctness, gets approved.
➖➖➖➖➖➖
📚 Article: [here]
🥳 Medium Article: [here]
➖➖➖➖➖➖
#softwareEngineering #softSkill
🖥 Follow @devDastan for more content.
The bottom layer is the correctness of the code, which is of prime importance.
➖➖➖➖➖➖
➖➖➖➖➖➖
#softwareEngineering #softSkill
Please open Telegram to view this post
VIEW IN TELEGRAM
👍8❤4🤯2
const box = { x: 10, y: 20 };
Object.freeze(box);
const shape = box;
shape.x = 100;
console.log(shape);
ReferenceErrorObject.freeze prevents adding, removing, or modifying properties of an object (unless the property’s value is another object).
When we create the variable shape and set it equal to the frozen object box, shape also refers to a frozen object. You can check if an object is frozen using Object.isFrozen. In this case, Object.isFrozen(shape) returns true.
Since shape is frozen and x is not an object, we cannot modify x. Therefore, x remains 10, and { x: 10, y: 20 } gets logged.
➖➖➖➖➖➖
#JavaScript #Quiz
Please open Telegram to view this post
VIEW IN TELEGRAM
👍16😎2🤯1
➖➖➖➖➖➖
➖➖➖➖➖➖
#angular
Please open Telegram to view this post
VIEW IN TELEGRAM
👍12❤1🤯1😎1
✨ Software Engineering Quote
💬 Even the most complex systems are inherently simple when viewed from the right angle.
🔣 Eliyahu M. Goldratt
➖➖➖➖➖➖
#softwareEngineering #systemDesign
🖥 Follow @devDastan for more content.
➖➖➖➖➖➖
#softwareEngineering #systemDesign
Please open Telegram to view this post
VIEW IN TELEGRAM
👍12❤1🤯1
Transform existing types by applying operations to each property. Useful for adding prefixes/suffixes to properties, creating key-value pairs from objects, etc.
interface User {
name: string;
age: number;
}
type ReadOnly<T> = { readonly [P in keyof T]: T[P] };
const readOnlyUser: ReadOnly<User> = {
name: 'Kurt',
age: 27
};
// readOnlyUser.name = 'Chester';
// Error: Cannot assign to 'name' because it is a read-only property
Useful for manipulate and transform data from the API or before passing data to another component, with different data types.
➖➖➖➖➖➖
#TypeScript
Please open Telegram to view this post
VIEW IN TELEGRAM
👍11❤2🤯1
➖➖➖➖➖➖
➖➖➖➖➖➖
#softwareEngineering #security
Please open Telegram to view this post
VIEW IN TELEGRAM
👍18❤1
✨ Explaining Software Development Methods Comic
➖➖➖➖➖➖
📚 Article: [here]
➖➖➖➖➖➖
#softwareEngineering #softwareDevelopment #comic
🖥 Follow @devDastan for more content.
➖➖➖➖➖➖
➖➖➖➖➖➖
#softwareEngineering #softwareDevelopment #comic
Please open Telegram to view this post
VIEW IN TELEGRAM
👍8❤4🍌4😎1
As a developer you will code 20% of your time. You should excel at coding nonetheless, but it won't be enough to be great
Making sure everything around you runs smoothly and has forward momentum
Build projects, try out frameworks, build stuff on the side. Keeps the spark alive
It's important to know why your code does what it does, too many abstractions nowadays that rarely someone thinks below the level of their language e.g JS devs not thinking about the engine that runs their code
Knowing how your code impacts not only your individual system but other parts of the business/application/life
Recharging away from your monitor makes you a better programmer
Knowing important tech numbers to approximate calculations when making decisions when programming
➖➖➖➖➖➖
➖➖➖➖➖➖
#softwareEngineering #softSkill
Please open Telegram to view this post
VIEW IN TELEGRAM
👍10❤3🤯3
➖➖➖➖➖➖
➖➖➖➖➖➖
#softwareEngineering #softSkill
Please open Telegram to view this post
VIEW IN TELEGRAM
👍11❤2🍌1
➖➖➖➖➖➖
➖➖➖➖➖➖
#softwareEngineering #softSkill
Please open Telegram to view this post
VIEW IN TELEGRAM
👍13❤4🤯1