When we need a same values of type for different constants, instead of repeating the code, we can simply do as example; type Employee={name: string, id: number} let user: Employee={name:"Ram",id:10} Here, we use *type* to create an object type that can be used for other constants without repeating the code.
Null cannot be used like we use in JS. Null is hardly used and we we must use we should modify the function itself like; function name(first=string | null){console.log("Hi")} name(null); Here we defined that the value may also be a null for null to act without errors.
Comments
Post a Comment