Files
30-seconds-of-code/snippets/js/s/current-url.md
2023-05-07 16:07:29 +03:00

21 lines
331 B
Markdown

---
title: Current URL
type: snippet
language: javascript
tags: [browser]
cover: tropical-bike
dateModified: 2020-10-20T11:46:23+03:00
---
Returns the current URL.
- Use `Window.location.href` to get the current URL.
```js
const currentURL = () => window.location.href;
```
```js
currentURL(); // 'https://www.google.com/'
```