Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Template strings in ES2015

What is the meaning of "passed array is frozen" in the context of template strings in ES2015?

Source: http://node.green

like image 522
Ben Aston Avatar asked Jun 30 '26 11:06

Ben Aston


1 Answers

It doesn't mean any special in the context of template strings. It just means that the array is frozen. From the docs:

An object is frozen if and only if it is not extensible, all its properties are non-configurable, and all its data properties (that is, properties which are not accessor properties with getter or setter components) are non-writable.

So the array of strings that is getting passed into the tag function is essentially immutable. This is supposed to allow engines to store it as a constant and repeatedly pass the same array object every time the tagged template literal is evaluated.

like image 187
Bergi Avatar answered Jul 02 '26 00:07

Bergi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!