Using closures this way is a nice touch! It's true that the secret variable inside checkSecret can't be changed, however I would be careful not to add anything too secret this way, as checkSecret.toString() returns
secret
checkSecret
checkSecret.toString()
"() => { const secret = 'pillow' // gets tossed into the bin! return attempt => { return secret === attempt } }"
thus revealing the secret string.
👍 Right! Put actual secrets into .env variables.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Using closures this way is a nice touch! It's true that the
secret
variable insidecheckSecret
can't be changed, however I would be careful not to add anything too secret this way, ascheckSecret.toString()
returnsthus revealing the secret string.
👍 Right! Put actual secrets into .env variables.