It is a really good feature coming with TypeScript 5.0. We could infer type of object as general as shown in line 8 in below code, so, to infer more-specific type, we had to add as const as shown in line 11.
TypeScript 5.0 makes it easier with adding const in front of type parameter declaration in line 13 in below code.
Assume that Person type has hobbies , and i just want to infer passed values from hobbies field.
I don't know how to emphasise how much closures are important 🙂 but if you are not aware of it, you may face many unpredictable and unexpected issues in your code. Even you are aware of it, you may still have some logical problem due to "Function Closure"
A Function is much the same as a Procedure or a Subroutine, in other programming languages.
You can reuse code: Define the code once, and use it many times.
You can use the same code many times with different arguments, to produce different results.
Function Declaration (function statement)
Self-Invoking Function (Immediately Invokable Function ExpressionIIFE)