There are a log of question on JavaScript scope, but none that address my exact issue.
How do I access the user
object inside my script, and why is it not visible?
My app renders a .ejs page. Consider the following code:
<html>
<body>
...some stuff
<% if (user.local.email) { %> <!-- WORKS PERFECTLY -->
... some stuff
<% } %>
<script>
$(document).ready(function() {
console.log(user); //-- DOES NOT WORK
} //-- REFERENCE ERROR: USER NOT DEFINED
</script>
</body>
</html>
I don't understand why user
is visible in one part of the page, but not in the script below it?