---
title: "Discussion on \"JavaScript: How to get the URL parts from a URL\" | Hashnode"
description: "Discussion on \"JavaScript: How to get the URL parts from a URL\". const url = new URL('http://example.com:12345/blog/foo/bar?startIndex=1&pageSize=10');\nconst { protocol, hostname, port, pathname, search } = url;\n\nconsole.log('protocol =>', protocol);\nconsole.log('hostname =>', hostname);\nconsole.log('port =>', por..."
url: "https://hashnode.com/posts/javascript-how-to-get-the-url-parts-from-a-url/63294be8195e7dc741da6f9b"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [JavaScript: How to get the URL parts from a URL](https://harikrishna.hashnode.dev/javascript-how-to-get-the-url-parts-from-a-url?utm_source=hashnode&utm_medium=feed)

const url = new URL('http://example.com:12345/blog/foo/bar?startIndex=1&pageSize=10'); const { protocol, hostname, port, pathname, search } = url; console.log('protocol =>', protocol); console.log('hostname =>', hostname); console.log('port =>', por...

Jan 18, 2022 · 1 min read · harikrishna.hashnode.dev  
Read the article

-   [#url](https://hashnode.com/tag/url)
-   [#pathname](https://hashnode.com/tag/pathname)
-   [#protocol](https://hashnode.com/tag/protocol)
-   [#query-string](https://hashnode.com/tag/query-string)
-   [#host](https://hashnode.com/tag/host)

## Written by

[Hari Krishna Anem](https://hashnode.com/@hkrishna)

@hkrishna · Hyderabad, India

  
[View profile](https://hashnode.com/@hkrishna)

Full stack developer

Full stack developer (ReactJS, NodeJS, JavaScript, PHP, SQL)

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
