AWessel's avatar

AWessel wrote a comment+100 XP

3mos ago

Beginning TypeScript: Ep 6, Any and Unknown

@timsims Super Tipp! (Which of course I already knew...pfff! ;-) )

AWessel's avatar

AWessel liked a comment+100 XP

3mos ago

Beginning TypeScript: Ep 6, Any and Unknown
if (
unknownFoo.prop2 
&& typeof unknownFoo.prop2 === 'object' 
&& 'foo' in unknownFoo.prop2
) {
    console.log(unknownFoo.prop2.foo);
}

keyword in can do the trick

AWessel's avatar

AWessel wrote a comment+100 XP

3mos ago

Learn Vue 3: Step by Step: Ep 19, From Mixins to Composables

@Ispilledteaonthecarpet For a stateless method, like flash, this wouldn't make any difference. But usually you have bundled several members together (functions, private/inner functions, state variables). Imagine the good old car example with accelerate, brake and currentSpeed. All members of useCar would work with the same speed state. And if you use the useCar composable at different components each component has a separate useCar state.