본문 바로가기

Vanilla JS

[자바스크립트] URL에서 특정 파라미터 찾기

//.com/manage/newpost/?type=post

const url = new URL(window.location.href)
const urlParams = url.searchParams

urlParams.get('type')
//'post'