Search code examples
angularjsangularsyntaxsemanticsstring-interpolation

Why double curly braces in Angular/JS are called interpolation?


After more than a year of working with Angular/JS, I still don't have an intuitive understanding of what is interpolation (e.g. {{1+4}} ). What is the origin of the of the term (in Angular/JS context) and does it have anything in common with the mathematical term?


Solution

  • "Interpolation - the insertion of something of a different nature into something else".

    It's a term used for embedding expressions into template literal, which work as placeholders.

    In JavaScript you can have the same concept with string interpolation:

    var a = 1;
    var b = 4;
    console.log(`Interpolated result is: ${a+b}`); // note: the quotes ``