Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
</body>
</html>
 
// https://stackoverflow.com/a/41015840/2125837
console.log('template string');
String.prototype.interpolate = function(params) {
  const names = _.keys(params);
  const vals = _.values(params);
  return new Function(...names, `return \`${this}\`;`)(...vals);
}
const template = 'Example text: ${text}';
const result = template.interpolate({text: 'Foo Boo'});
console.log(result);
console.log('template string');
Output 300px

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
suntongpro
0viewers