Js constants with variables inside.
Posted
by johnnyArt
on Stack Overflow
See other posts from Stack Overflow
or by johnnyArt
Published on 2010-03-14T18:12:19Z
Indexed on
2010/03/14
18:25 UTC
Read the original article
Hit count: 451
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.
© Stack Overflow or respective owner