Declare object and set variable in one line of code

Let's assume that you want to create an object and declare a property (variable) in a single line of code:

// Getting current URL
let url = window.location.href;

// Creating object and declaring property 
let urlVisited = {[url]: true};

Hi, I'm Erik, an engineer from Barcelona. If you like the post or have any comments, say hi.