window.localStroage is a more modern alternative to cookies. It allows you to store (semi-)persistent data in the users web browser which will survive a browser restart. The client-sided javascript can access it without having to consult a server, which makes it quite fast to access from the client. But contrary to cookies, localstorage is not directly accessible for the server. When you need data from localstorage on the server, you need to send it to the server via AJAX or websockets after the website has loaded.
localStorage has a much higher capacity than cookies, but not unlimited. The standard suggests 5MB, but that's just a suggestion. Most browsers have a higher limit and react differently when it is exceeded. Some ask the user for permission to store more, some just drop any excess data. But you can not be sure how the browser reacts, so you should try to stay below the 5MB limit.
Keep in mind that localStorage doesn't guarantee persistence. The user can accidentally or intentionally delete their localstorage, just like they can delete cookies. Also, the web browser might have a combined hard-drive quota for localstorage for all websites and delete arbitrary data when running out.
The localstorage also doesn't guarantee integrity. The user can manipulate their localstorage. That means when you store any game state in it, you have to assume that the user will be able to edit it in any way they want, allowing them to cheat. When your game is single-player, that might not be that much of an issue. But when your game has any interaction between players (and when it's just a public scoreboard), cheaters might be quite an annoyance for the more honest players.
However, localstorage has the advantage over server-sided persistence that you do not need personalized user accounts. The data is bound to the web browser installation, so the user can save their game without having to register and log into an account. You also don't need a server-sided database which greatly simplifies your server infrastructure.