⚡ JavaScript & TypeScript Daily Refresher #62 👉 When do you use export default and when export in TypeScript? 💡 Use export for named exports when a file contains multiple items. Use export default for a single main value — like React components or utility modules with one primary function. ✨ I post daily JS/TS refreshers — follow for the next one! #JavaScript #TypeScript #React #WebDevelopment
Majid Abbasi’s Post
More Relevant Posts
-
⚡ JavaScript & TypeScript Daily Refresher #73 👉 I have a User type where all properties are required, but for a patch operation, I want to make all properties optional except id. How would you do this? 💡 Use utility types — Partial<User> makes all properties optional, and you can combine it with Pick or & to keep id required: type PatchUser = Partial<User> & Pick<User, "id"> ✨ I post daily JS/TS refreshers — follow for the next one! #JavaScript #TypeScript #UtilityTypes #WebDevelopment
To view or add a comment, sign in
-
⚡ JavaScript & TypeScript Daily Refresher #77 👉 What is the return type of a setter function in TypeScript? 💡 Setter functions should not have a return type at all — they’re meant only to update a property’s value, not return anything. ✨ I post daily JS/TS refreshers — follow for the next one! #JavaScript #TypeScript #OOP #WebDevelopment
To view or add a comment, sign in
-
⚡ JavaScript & TypeScript Daily Refresher #88 👉 What is a “never check” in TypeScript? 💡 A never check happens when TypeScript confirms that all possible cases of a union are handled — anything left falls into the never type, helping you catch missing branches at compile time. ✨ I post daily JS/TS refreshers — follow for the next one! #JavaScript #TypeScript #AdvancedTypes #WebDevelopment
To view or add a comment, sign in
-
⚡ JavaScript & TypeScript Daily Refresher #89 👉 What are function overloads in TypeScript? 💡 Function overloads let you define multiple call signatures for one function, so TypeScript can offer better type safety and autocomplete based on how the function is called. ✨ I post daily JS/TS refreshers — follow for the next one! #JavaScript #TypeScript #FunctionOverloads #WebDevelopment
To view or add a comment, sign in
-
⚡ JavaScript & TypeScript Daily Refresher #85 👉 What is a predicate in TypeScript? 💡 A predicate is a special return type used in custom type guards — it tells TypeScript that a function checks a specific type. Example: function isString(value: unknown): value is string { return typeof value === "string"; } ✨ I post daily JS/TS refreshers — follow for the next one! #JavaScript #TypeScript #TypeGuards #WebDevelopment
To view or add a comment, sign in
-
⚡ JavaScript & TypeScript Daily Refresher #75 👉 How are classes different in TypeScript and JavaScript? 💡 They work the same at runtime — both compile to JavaScript classes. But TypeScript adds type checking, access modifiers, and interfaces, making class-based development more structured and safer. ✨ I post daily JS/TS refreshers — follow for the next one! #JavaScript #TypeScript #OOP #WebDevelopment
To view or add a comment, sign in
-
⚡ JavaScript & TypeScript Daily Refresher #86 👉 I have a type that’s a union of multiple types — what’s the side effect of using it? 💡 Unions can cause more complex narrowing because TypeScript must consider all possible types, which can lead to extra checks before accessing properties or calling methods. ✨ I post daily JS/TS refreshers — follow for the next one! #JavaScript #TypeScript #TypeNarrowing #WebDevelopment
To view or add a comment, sign in
-
⚡ JavaScript & TypeScript Daily Refresher #84 👉 What are type guards in TypeScript? 💡 Type guards are runtime checks that let TypeScript know more about a variable’s type within a block — for example: if (typeof value === "string") { /* value is a string here */ } ✨ I post daily JS/TS refreshers — follow for the next one! #JavaScript #TypeScript #TypeGuards #WebDevelopment
To view or add a comment, sign in
-
⚡ JavaScript & TypeScript Daily Refresher #83 👉 How do you check if TypeA is assignable to TypeB in TypeScript? 💡 Use a conditional type — for example: type Check = TypeA extends TypeB ? TypeC : TypeD This checks assignability at the type level and picks the result accordingly. ✨ I post daily JS/TS refreshers — follow for the next one! #JavaScript #TypeScript #AdvancedTypes #WebDevelopment
To view or add a comment, sign in
-
⚡ JavaScript & TypeScript Daily Refresher #87 👉 If you have a union of multiple custom types, how do you make narrowing easier? 💡 I add a discriminating field like "type" or "kind" — then I narrow based on that property, making the union much simpler and safer to work with. ✨ I post daily JS/TS refreshers — follow for the next one! #JavaScript #TypeScript #DiscriminatedUnions #WebDevelopment
To view or add a comment, sign in
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development