114
rated 0 times
[
121]
[
7]
/ answers: 1 / hits: 50267
/ 14 Years ago, fri, february 11, 2011, 12:00:00
Python has this beautiful function to turn this:
bar1 = 'foobar'
bar2 = 'jumped'
bar3 = 'dog'
foo = 'The lazy ' + bar3 + ' ' + bar2 ' over the ' + bar1
# The lazy dog jumped over the foobar
Into this:
bar1 = 'foobar'
bar2 = 'jumped'
bar3 = 'dog'
foo = 'The lazy {} {} over the {}'.format(bar3, bar2, bar1)
# The lazy dog jumped over the foobar
Does JavaScript have such a function? If not, how would I create one which follows the same syntax as Python's implementation?
More From » python