I am currently working on a JavaScript project and know that JavaScript source code is accessible through the browser. In the code, I have a variable that stores a secret string that is used by the program. However, I do not want others to view the source code and find out the value of this variable. Is there a way to hide the value of a variable? Or is it possible to change the variable value after? For instance, change the actual source code to set the variable to a different value? This variable is only used the first time an image is loaded so it would be okay to remove it altogether if that is possible.
You cannot hide JavaScript content from a programmer. They can always open the developer console and get all your variables.
What's worse, they can use said console to directly bypass any JavaScript validation, so it cannot be your primary security.
If it is something you must hide or secure against, you must look into a server side solution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With