{"id":71,"date":"2019-05-13T09:51:08","date_gmt":"2019-05-13T09:51:08","guid":{"rendered":"https:\/\/jnews.io\/tutorial\/?p=71"},"modified":"2019-06-18T05:33:26","modified_gmt":"2019-06-18T05:33:26","slug":"how-to-use-es6-template-literals-in-javascript","status":"publish","type":"post","link":"https:\/\/jnews.io\/tutorial\/2019\/05\/13\/how-to-use-es6-template-literals-in-javascript\/","title":{"rendered":"How to Use ES6 Template Literals in JavaScript"},"content":{"rendered":"<p>Strech lining hemline above knee burgundy glossy silk complete hid zip little catches rayon. Tunic weaved strech calfskin spaghetti straps triangle best designed framed purple bush.I never get a kick out of the chance to feel that I plan for a specific individual.<\/p>\n<p>Separated they live in Bookmarksgrove right at the coast of the Semantics, a large language ocean. A small river named Duden flows by their place and supplies it with the necessary regelialia. It is a paradisematic country, in which roasted parts of sentences fly into your mouth.<\/p>\n<pre class=\"lang:default decode:true\">function f (arg) {\r\n    var name = arg[0];\r\n    var val  = arg[1];\r\n    console.log(name, val);\r\n};\r\nfunction g (arg) {\r\n    var n = arg.name;\r\n    var v = arg.val;\r\n    console.log(n, v);\r\n};\r\nfunction h (arg) {\r\n    var name = arg.name;\r\n    var val  = arg.val;\r\n    console.log(name, val);\r\n};\r\nf([ \"bar\", 42 ]);\r\ng({ name: \"foo\", val:  7 });\r\nh({ name: \"bar\", val: 42 });<\/pre>\n<p>A wonderful serenity has taken\u00a0possession\u00a0of my entire soul, like these sweet mornings of spring which I enjoy with my whole heart. Even the all-powerful Pointing has no control about the blind texts it is an almost unorthographic life One day however a small line of blind text by the name of\u00a0Lorem Ipsumdecided to leave for the far World of Grammar. The Big Oxmox advised her not to do so, because there were thousands of bad Commas, wild Question Marks and devious Semikoli, but the Little Blind Text didn\u2019t listen.<\/p>\n<p>On her way she met a copy. The copy warned the Little Blind Text, that where it came from it would have been rewritten a thousand times and everything that was left from its origin would be the word \u201cand\u201d and the Little Blind Text should turn around and return to its own, safe country.<\/p>\n<h3>Syntax of Template Literals<\/h3>\n<p>But nothing the copy said could convince her and so it didn\u2019t take long until a few insidious Copy Writers ambushed her, made her drunk with Longe and Parole and dragged her into their agency, where they abused her for their projects again and again. And if she hasn\u2019t been rewritten, then they are still using her.<br \/>\nFar far away, behind the word mountains, far from the countries Vokalia and Consonantia, there live the blind texts. Separated they live in Bookmarksgrove right at the coast of the Semantics, a large language ocean. A small river named Duden flows by their place and supplies it with the necessary regelialia.<\/p>\n<p>Gregor then turned to look out the window at the dull weather. Drops of rain could be heard hitting the pane, which made him feel quite sad. \u201cHow about if I sleep a little bit longer and forget all this nonsense\u201d, he thought, but that was something he was unable to do because he was used to sleeping on his right, and in his present state couldn\u2019t get into that position. However hard he threw himself onto his right, he always rolled back to where he was.<\/p>\n<ul>\n<li>Responsive Design. Tested on Google Mobile Friendly<\/li>\n<li>Header Builder with Live Preview<\/li>\n<li>Optimized for Google Page Speed as SEO Signal<\/li>\n<\/ul>\n<p>Website schema using JSON LD which is recommended by GoogleI am so happy, my dear friend, so absorbed in the exquisite sense of mere tranquil existence, that I neglect my talents. I should be incapable of drawing a single stroke at the present moment; and yet I feel that I never was a greater artist than now.<\/p>\n<p>A collection of textile samples lay spread out on the table \u2013 Samsa was a travelling salesman \u2013 and above it there hung a picture that he had recently cut out of an illustrated magazine and housed in a nice, gilded frame. It showed a lady fitted out with a fur hat and fur boa who sat upright, raising a heavy fur muff that covered the whole of her lower arm towards the viewer.<\/p>\n<p>Even the all-powerful Pointing has no control about the blind texts it is an almost unorthographic life One day however a small line of blind text by the name of Lorem Ipsum decided to leave for the far World of Grammar. The Big Oxmox advised her not to do so, because there were thousands of bad Commas, wild Question Marks and devious Semikoli, but the Little Blind Text didn\u2019t listen.<\/p>\n<p>His room, a proper human room although a little too small, lay peacefully between its four familiar walls. A collection of textile samples lay spread out on the table \u2013 Samsa was a travelling salesman \u2013 and above it there hung a picture that he had recently cut out of an illustrated magazine and housed in a nice, gilded frame.<\/p>\n<p>Even the all-powerful Pointing has no control about the blind texts it is an almost unorthographic life One day however a small line of blind text by the name of Lorem Ipsum decided to leave for the far World of Grammar.<br \/>\nThe Big Oxmox advised her not to do so, because there were thousands of bad Commas, wild Question Marks and devious Semikoli, but the Little Blind Text didn\u2019t listen.<\/p>\n<pre class=\"lang:default decode:true\">\/\/  only in ES5 through the help of object properties\r\n\/\/  and only in global context and not in a block scope\r\nObject.defineProperty(typeof global === \"object\" ? global : window, \"PI\", {\r\n    value:        3.141593,\r\n    enumerable:   true,\r\n    writable:     false,\r\n    configurable: false\r\n})\r\nPI &gt; 3.0;<\/pre>\n<p>A collection of textile samples lay spread out on the table \u2013 Samsa was a travelling salesman \u2013 and above it there hung a picture that he had recently cut out of an illustrated magazine and housed in a nice, gilded frame. It showed a lady fitted out with a fur hat and fur boa who sat upright, raising a heavy fur muff that covered the whole of her lower arm towards the viewer.<\/p>\n<p>Website schema using JSON LD which is recommended by GoogleI am so happy, my dear friend, so absorbed in the exquisite sense of mere tranquil existence, that I neglect my talents. I should be incapable of drawing a single stroke at the present moment; and yet I feel that I never was a greater artist than now.<\/p>\n<p>His room, a proper human room although a little too small, lay peacefully between its four familiar walls. A collection of textile samples lay spread out on the table \u2013 Samsa was a travelling salesman \u2013 and above it there hung a picture that he had recently cut out of an illustrated magazine and housed in a nice, gilded frame.<\/p>\n<pre class=\"lang:default decode:true\">var params = [ \"hello\", true, 7 ];\r\nvar other = [ 1, 2 ].concat(params); \/\/ [ 1, 2, \"hello\", true, 7 ]\r\n\r\nfunction f (x, y) {\r\n    var a = Array.prototype.slice.call(arguments, 2);\r\n    return (x + y) * a.length;\r\n};\r\nf.apply(undefined, [ 1, 2 ].concat(params)) === 9;\r\n\r\nvar str = \"foo\";\r\nvar chars = str.split(\"\"); \/\/ [ \"f\", \"o\", \"o\" ]<\/pre>\n<p>Even the all-powerful Pointing has no control about the blind texts it is an almost unorthographic life One day however a small line of blind text by the name of Lorem Ipsum decided to leave for the far World of Grammar. The Big Oxmox advised her not to do so, because there were thousands of bad Commas, wild Question Marks and devious Semikoli, but the Little Blind Text didn\u2019t listen.<\/p>\n<p>A collection of textile samples lay spread out on the table \u2013 Samsa was a travelling salesman \u2013 and above it there hung a picture that he had recently cut out of an illustrated magazine and housed in a nice, gilded frame. It showed a lady fitted out with a fur hat and fur boa who sat upright, raising a heavy fur muff that covered the whole of her lower arm towards the viewer.<\/p>\n<p>Website schema using JSON LD which is recommended by GoogleI am so happy, my dear friend, so absorbed in the exquisite sense of mere tranquil existence, that I neglect my talents. I should be incapable of drawing a single stroke at the present moment; and yet I feel that I never was a greater artist than now.<\/p>\n<p>A wonderful serenity has taken\u00a0possession\u00a0of my entire soul, like these sweet mornings of spring which I enjoy with my whole heart. Even the all-powerful Pointing has no control about the blind texts it is an almost unorthographic life One day however a small line of blind text by the name of\u00a0Lorem Ipsumdecided to leave for the far World of Grammar. The Big Oxmox advised her not to do so, because there were thousands of bad Commas, wild Question Marks and devious Semikoli, but the Little Blind Text didn\u2019t listen.<\/p>\n<h3>Tagged Templates<\/h3>\n<p>On her way she met a copy. The copy warned the Little Blind Text, that where it came from it would have been rewritten a thousand times and everything that was left from its origin would be the word \u201cand\u201d and the Little Blind Text should turn around and return to its own, safe country.<\/p>\n<p>A wonderful serenity has taken\u00a0possession\u00a0of my entire soul, like these sweet mornings of spring which I enjoy with my whole heart. Even the all-powerful Pointing has no control about the blind texts it is an almost unorthographic life One day however a small line of blind text by the name of\u00a0Lorem Ipsumdecided to leave for the far World of Grammar. The Big Oxmox advised her not to do so, because there were thousands of bad Commas, wild Question Marks and devious Semikoli, but the Little Blind Text didn\u2019t listen<\/p>\n<pre class=\"lang:default decode:true \">\/\/  generic asynchronous control-flow driver\r\nfunction async (proc, ...params) {\r\n    let iterator = proc(...params)\r\n    return new Promise((resolve, reject) =&gt; {\r\n        let loop = (value) =&gt; {\r\n            let result\r\n            try {\r\n                result = iterator.next(value)\r\n            }\r\n            catch (err) {\r\n                reject(err)\r\n            }\r\n            if (result.done)\r\n                resolve(result.value)\r\n            else if (   typeof result.value      === \"object\"\r\n                     &amp;&amp; typeof result.value.then === \"function\")\r\n                result.value.then((value) =&gt; {\r\n                    loop(value)\r\n                }, (err) =&gt; {\r\n                    reject(err)\r\n                })\r\n            else\r\n                loop(result.value)\r\n        }\r\n        loop()\r\n    })\r\n}\r\n\r\n\/\/  application-specific asynchronous builder\r\nfunction makeAsync (text, after) {\r\n    return new Promise((resolve, reject) =&gt; {\r\n        setTimeout(() =&gt; resolve(text), after)\r\n    })\r\n}\r\n\r\n\/\/  application-specific asynchronous procedure\r\nasync(function* (greeting) {\r\n    let foo = yield makeAsync(\"foo\", 300)\r\n    let bar = yield makeAsync(\"bar\", 200)\r\n    let baz = yield makeAsync(\"baz\", 100)\r\n    return `${greeting} ${foo} ${bar} ${baz}`\r\n}, \"Hello\").then((msg) =&gt; {\r\n    console.log(\"RESULT:\", msg) \/\/ \"Hello foo bar baz\"\r\n})\r\n<\/pre>\n<p>On her way she met a copy. The copy warned the Little Blind Text, that where it came from it would have been rewritten a thousand times and everything that was left from its origin would be the word \u201cand\u201d and the Little Blind Text should turn around and return to its own, safe country.<\/p>\n<h3><\/h3>\n","protected":false},"excerpt":{"rendered":"<p>Strech lining hemline above knee burgundy glossy silk complete hid zip little catches rayon. Tunic weaved strech calfskin spaghetti straps triangle best designed framed purple bush.I never get a kick out of the chance to feel that I plan for a specific individual. Separated they live in Bookmarksgrove right at the coast of the Semantics, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":191,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jnews-multi-image_gallery":[],"jnews_single_post":{"source_name":"","source_url":"","via_name":"","via_url":"","override_template":"0","override":[{"template":"1","single_blog_custom":"","parallax":"1","fullscreen":"0","layout":"right-sidebar","sidebar":"default-sidebar","second_sidebar":"default-sidebar","sticky_sidebar":"1","share_position":"top","share_float_style":"share-monocrhome","show_share_counter":"1","show_view_counter":"1","show_featured":"1","show_post_meta":"1","show_post_author":"1","show_post_author_image":"1","show_post_date":"1","post_date_format":"default","post_date_format_custom":"Y\/m\/d","show_post_category":"1","show_post_reading_time":"0","post_reading_time_wpm":"300","show_zoom_button":"0","zoom_button_out_step":"1","zoom_button_in_step":"1","show_post_tag":"1","show_prev_next_post":"1","show_popup_post":"1","number_popup_post":"1","show_author_box":"0","show_post_related":"0","show_inline_post_related":"0"}],"override_image_size":"0","image_override":[{"single_post_thumbnail_size":"crop-500","single_post_gallery_size":"crop-500"}],"trending_post":"0","trending_post_position":"meta","trending_post_label":"Trending"},"jnews_primary_category":{"id":""},"jnews_social_meta":{"fb_title":"","fb_description":"","fb_image":"","twitter_title":"","twitter_description":"","twitter_image":""},"jnews_override_counter":{"override_view_counter":"0","view_counter_number":"0","override_share_counter":"0","share_counter_number":"0","override_like_counter":"0","like_counter_number":"0","override_dislike_counter":"0","dislike_counter_number":"0"},"footnotes":""},"categories":[8,7,3],"tags":[26],"class_list":["post-71","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-coding","category-design","category-technology","tag-javascript"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/jnews.io\/tutorial\/wp-json\/wp\/v2\/posts\/71","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jnews.io\/tutorial\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jnews.io\/tutorial\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jnews.io\/tutorial\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jnews.io\/tutorial\/wp-json\/wp\/v2\/comments?post=71"}],"version-history":[{"count":4,"href":"https:\/\/jnews.io\/tutorial\/wp-json\/wp\/v2\/posts\/71\/revisions"}],"predecessor-version":[{"id":500,"href":"https:\/\/jnews.io\/tutorial\/wp-json\/wp\/v2\/posts\/71\/revisions\/500"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/jnews.io\/tutorial\/wp-json\/wp\/v2\/media\/191"}],"wp:attachment":[{"href":"https:\/\/jnews.io\/tutorial\/wp-json\/wp\/v2\/media?parent=71"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jnews.io\/tutorial\/wp-json\/wp\/v2\/categories?post=71"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jnews.io\/tutorial\/wp-json\/wp\/v2\/tags?post=71"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}