Typescript

PHOTO EMBED

Fri Oct 21 2022 16:21:13 GMT+0000 (Coordinated Universal Time)

Saved by @phansivang #typescript

//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)

content_copyCOPY