How can I get public files path in javascript files? I want to display files present in the public folder(sites/default/files). So in the module file when I click on a link it will call to js function, How can I get all file names which are present in the public folder in js file.
It depends where you are storing all your files, to use the base url of your site you need to do this:

$base_url."/sites/default/files/xxx.jpg"


If your files are inside some theme:

$base_url."/".drupal_get_path('theme', 'name_theme')."/images/xxx.png


If you are using files with public://, use this:

$uri = $your_file_name; // Example "public://xxx"
$path= file_create_url($uri);


I hope it works in your case