How to set custom variable only on first visit?

Is there any on-board solution that allows me to check if the customer visits the site the first time in JS, or do I have to use an own cookie?