//ENUM
enum userProfile {
firstName = "Cheng",
lastName = "Phansivang",
bio = "I love virak pech my baby",
}
const { firstName, lastName, bio} = userProfile;
//INTERFACE
interface profile{
userName:string,
password:number,
}
const proFile: profile = {
userName:"Phansivang",
password:2222,
}
// UNION TYPE
function texing(userName:string|number){
console.log(userName);
}
// FUNCTION WITH VOID // VOID CAN'T RETURN THE VALUE
function userName():void{
console.log("Phansivang");
}
userName()
// OPTIONAL PARAMETERS
function myNumber(x:number, y:number, o?:number){
console.log(x + y + (o || 0))
}
myNumber(2,3)
// CASTING AS
const lengleng = "5454545";
console.log(typeof (lengleng as string).length)
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter