Now you have a userID property on the window Object. You could, of course, define a different structure if your app needs other data shared from PHP, but the general idea would be the same.
This is a Laracasts package that was the subject of a video tutorial a number of years ago - it supports Laravel 8; but it should not be necessary unless you are passing a lot of data dynamically to the frontend:
@tykus Thanks for your reponse sir, but I've already tried this.
I put this code in one of my views (in the script tag) and when i go to my bootstrap.js file and I console.log() my window object, i don't find my property.
@the beginner Why are you trying to get sensitive server-side data like the authenticated user, into your JavaScript? What are you wanting to do with the authenticated user object once you have it?