O'Reilly logo

Java 9 Cookbook by Nick Samoylov, Mohamed Sanaulla

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How to do it... 

  1. Template strings are strings with variable placeholders, thereby allowing the creation of dynamic texts. The strings have to be embedded within the symbols ``:
        var name = "Sanaulla";        print(`My name is ${name}`);
  1. Any variable in JavaScript has a global scope. ES6 introduced the block scope, which can be declared using the let keyword. Constants can now be defined using the const keyword, as shown in the following code snippet:
        const pi = 3.14;        var language = "Java";        function hello(){          let name = "Mohamed";          language = "Javascript";          print(`From hello(). Hello ${name}`);          print(`From hello(). Language is ${language}`);        }        print(`Before hello(). Language is ${language}`);        hello();        print(`After hello(). Language is ${language ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required