javascript: pass the magento username and email variables to the js script





I would like to pass the user's name and email to my js chat script. I know I should be able to capture the client session using the object manager in this way:

get (& # 39; Magento  Customer  Model  Session & # 39;);
if ($ customerSession-> isLoggedIn ()) {
echo $ customerSession-> getCustomer () -> getId (). "
"; // get client ID echo $ customerSession-> getCustomer () -> getName (). "
"; // get the full name echo $ customerSession-> getCustomer () -> getEmail (). "
"; // get the name of the email echo $ customerSession-> getCustomer () -> getGroupId (). "
"; // get customer group ID } ?>

Would the two variables pass by simply echoing within the quotes?