Files
30-seconds-of-code/snippets/currentURL.md
2022-02-13 18:10:27 +02:00

19 lines
318 B
Markdown

---
title: Current URL
tags: browser,beginner
firstSeen: 2017-12-18T11:05:03+02:00
lastUpdated: 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/'
```