How to pass a map from controller to javascript function in VF page

JavaScript
public String getButtonNameMap() {
  Map<String, Id> buttonNameMap = new Map<String, Id>();
  for(LiveChatButton chatButton:[SELECT DeveloperName FROM LiveChatButton WHERE DeveloperName =:buttonNamesSet LIMIT :Limits.getLimitQueryRows() - Limits.getQueryRows()] ) {
    buttonNameMap.put(chatButton.DeveloperName,chatButton.Id); 
   }
   return JSON.serialize(buttonNameMap);
}
Source

Also in JavaScript: