window.location.href
// http://localhost:8080/contents?type=0
window.location.protocol
// http:
window.location.host
// localhost:8080
window.location.hostname
//localhost
window.location.port
//8080
window.location.pathname
// /contents
window.location.search
// ?type=0
var target = typeof window.location.href;
console.log(target);
// string
타입 검사해보면 문자열로 반환해줌
나는 여기서 끝에자리만 필요함.
var target = window.location.href.slice(-1);
console.log(target);
// 0 whatever
출처