Js constants with variables inside
I know I'm able to this in PHP, but I can't remember the name or the way to do it, so I'll just explain what it is, and when someone tells me开发者_如何转开发 how it's called I'll update this question. I have some error messages defined as constants on javascript, however, some of those messages need to contain dynamic part as in the following example.
"The username must be between 4 and 20 characters"
In php, If I'm not mistaken there was some option for storing that string in a way that when called it would replace the variables with the data provided on the call. I want to do that on javascript, something like:
config['string',vars]
And have javascript insert those vars inside the string so it's customized. Wow, this must be the worst question I've made! I'm sorry for the lack of information, I'm kinda braindead on Sundays.
There isn't built-in functionality for such a behavior, but you can define it yourself or use the ones existing in various frameworks.
精彩评论