> From: [email protected]
> Date: Tue, 23 Dec 2014 14:55:57 +0800
>
> Given an array of [1,2,3] and other array of [“a”,”b”], it should return 
> [1,”a”,2,“b”,3]. (probably a lot of edge cases to cover, but just ignore them 
> for now).

I came up with an idea. Symmetric to String.raw, we can have a function that 
represents the default procedure.

```js
String.default=(a,...b)=>{
    let ret="";
    for(let i=0;ret+=a[i],i<b.length;ret+=b[i],i++);
    return ret;
};
```

So in semantics, String.default `Template` === `Template`. By introducing this, 
we can define a common procedure between tagged and untagged templates: 
untagged templates are equivalent to the tagged ones with tag String.default.

When implementing our own template functions, we can use:

```js
function custom(template, ...substitutions){
    // Perform actions on substitutions or template
    return String.default(template, ...substitutions);
}
```


                                          
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to