When i am setting up a new application it says near the Client ID value: "Your Client ID. Copy and keep it secure".
As per my understanding, i should specify this value inside my javascript functions so its not so secured.
No, you are correct. It is the combination of both Client ID and Client secret that you need to keep secure.