<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Pro-Tek Blog &#187; Ecmascript</title>
	<atom:link href="http://www.pro-tekconsulting.com/blog/category/ecmascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.pro-tekconsulting.com/blog</link>
	<description>For UI developers / UI designers and UI trends</description>
	<lastBuildDate>Thu, 05 Sep 2019 03:59:47 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.0.34</generator>
	<item>
		<title>FEATURES OF ECMASCRIPT6</title>
		<link>http://www.pro-tekconsulting.com/blog/features-of-ecmascript6/</link>
		<comments>http://www.pro-tekconsulting.com/blog/features-of-ecmascript6/#comments</comments>
		<pubDate>Wed, 02 Nov 2016 02:17:21 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[Ecmascript]]></category>
		<category><![CDATA[Features of Ecmascript6]]></category>

		<guid isPermaLink="false">http://www.pro-tekconsulting.com/blog/?p=1698</guid>
		<description><![CDATA[<p>Features of Ecmascript6 EcmaScript is the standardized scripting language that JavaScript implements. JavaScript is one of the most essential languages in existence today. Every browser has a JavaScript interpreter. JavaScript on the server is becoming more popular, and now we are able to use JavaScript for desktop (Chrome Apps), native mobile (PhoneGap) and native Windows [&#8230;]</p>
<p>The post <a rel="nofollow" href="http://www.pro-tekconsulting.com/blog/features-of-ecmascript6/">FEATURES OF ECMASCRIPT6</a> appeared first on <a rel="nofollow" href="http://www.pro-tekconsulting.com/blog">Pro-Tek Blog</a>.</p>
]]></description>
				<content:encoded><![CDATA[<h4>Features of Ecmascript6</h4>
<p>EcmaScript is the standardized scripting language that JavaScript implements. JavaScript is one of the most essential languages in existence today. Every browser has a JavaScript interpreter. JavaScript on the server is becoming more popular, and now we are able to use JavaScript for desktop (Chrome Apps), native mobile (PhoneGap) and native Windows 8 apps.</p>
<p>EcmaScript6 you’ve probably heard about it. It is the next version of JavaScript and it has some great new features. These features are varying degrees of complexities and are useful in both simple scripts and complex applications. In this article, we are going to discuss the major features of ES6 that you can use in your everyday JavaScript coding.</p>
<p><strong>BLOCK SCOPING</strong></p>
<p>Scoping in JavaScript is a bit confusing for the developers with C,C#, and Java background. In ES5, variables are either globally or locally scoped. The lack of block scoping has caused confusion in ES5 and resulted in some of the interesting patterns to achieve block scope. In ES6 a user can use let keyword to achieve block scoping.</p>
<p class="western"><span style="font-family: Calibri, serif;"><span style="font-size: small;"><span lang="en">var num = 0; //globally scoped</span></span></span></p>
<p class="western"><span style="font-family: Calibri, serif;"><span style="font-size: small;"><span lang="en">for (let i = 0; i &lt; 10; i++) { //i is block scoped</span></span></span></p>
<p class="western"><span style="font-family: Calibri, serif;"><span style="font-size: small;"><span lang="en">num += i;</span></span></span></p>
<p class="western"><span style="font-family: Calibri, serif;"><span style="font-size: small;"><span lang="en">console.log(&#8216;value of i in block: &#8216; + i);</span></span></span></p>
<p class="western"><span style="font-family: Calibri, serif;"><span style="font-size: small;"><span lang="en">}</span></span></span></p>
<p class="western"><span style="font-family: Calibri, serif;"><span style="font-size: small;"><span lang="en">console.log(&#8216;Is i defined here?: &#8216; + (typeof i !== &#8216;undefined&#8217;)); //Is i defined here?: false </span></span></span></p>
<p><strong>CONST</strong></p>
<p>There is another way to declare block-scoped variables. With const, a user can declare a read-only reference to a value. A user has to assign a variable directly. If a user tries to change the variable or if a user doesn’t set a value immediately, then the user gets an error.</p>
<p>const MY_CONSTANT = 1;<br />
MY_CONSTANT = 2 // Error<br />
const SOME_CONST; // Error<br />
<strong>Arrow Functions</strong></p>
<p>Arrow functions are the great inclusion to the JavaScript language. Many features in ES6 could fundamentally change and new JavaScript applications are architected. Arrow functions are not going to fundamentally change anything.</p>
<p class="western"><span style="font-family: Calibri, serif;"><span style="font-size: small;"><span lang="en">let books = [{title: &#8216;X&#8217;, price: 10}, {title: &#8216;Y&#8217;, price: 15}];</span></span></span></p>
<p class="western"><span style="font-family: Calibri, serif;"><span style="font-size: small;"><span lang="en">let titles = books.map( item =&gt; item.title );</span></span></span></p>
<p class="western"><span style="font-family: Calibri, serif;"><span style="font-size: small;"><span lang="en">// ES5 equivalent:</span></span></span></p>
<p class="western"><span style="font-family: Calibri, serif;"><span style="font-size: small;"><span lang="en">var titles = books.map(function(item) {</span></span></span></p>
<p class="western"><span style="font-family: Calibri, serif;"><span style="font-size: small;"><span lang="en">return item.title;</span></span></span></p>
<p class="western"><span style="font-family: Calibri, serif;"><span style="font-size: small;"><span lang="en">});</span></span></span></p>
<p>If we look at the syntax of arrow functions, there is no function keyword. What remains is zero or more arguments, the “arrow” (=&gt;) and the function expression. The return statement is unconditionally added.</p>
<p><strong>METHODS </strong></p>
<p>A couple of convenience methods have been added to the String prototype. Most of them basically phase-out some workarounds with the indexOf()method to achieve the same.</p>
<p class="western"><span style="font-family: Calibri, serif;"><span style="font-size: small;"><span lang="en">&#8216;my string&#8217;.startsWith(&#8216;my&#8217;); //true</span></span></span></p>
<p class="western"><span style="font-family: Calibri, serif;"><span style="font-size: small;"><span lang="en">&#8216;my string&#8217;.endsWith(&#8216;my&#8217;); // false</span></span></span></p>
<p class="western"><span style="font-family: Calibri, serif;"><span style="font-size: small;"><span lang="en">&#8216;my string&#8217;.includes(&#8216;str&#8217;); // true</span></span></span></p>
<p><strong>MODULES</strong></p>
<p>Modules have the prospective to radically change how many JavaScript applications are structured and standardized. Modules in ES6 provides a way to load and manage dependencies through the new import and export keywords.</p>
<p><strong>PROMISES </strong></p>
<p>Promises provide a mechanism to handle the results and errors from asynchronous operations. Promises provide more readability through method chaining succinct error handling. Promises are currently used in many JavaScript libraries. RSVP.js, Q.js, and the $q service in Angular.</p>
<p class="western"><span style="font-family: Calibri, serif;"><span style="font-size: small;"><span lang="en">getJSON(&#8220;/api/employee/1&#8243;).then(function(post) {</span></span></span></p>
<p class="western"><span style="font-family: Calibri, serif;"><span style="font-size: small;"><span lang="en">return getJSON(post.commentURL);</span></span></span></p>
<p class="western"><span style="font-family: Calibri, serif;"><span style="font-size: small;"><span lang="en">}).then(function(comments) { //you could chain multiple then statements</span></span></span></p>
<p class="western"><span style="font-family: Calibri, serif;"><span style="font-size: small;"><span lang="en">// proceed with access to employee</span></span></span></p>
<p class="western"><span style="font-family: Calibri, serif;"><span style="font-size: small;"><span lang="en">}).catch(function(error) { //succinct error handling</span></span></span></p>
<p class="western"><span style="font-family: Calibri, serif;"><span style="font-size: small;"><span lang="en">// handle errors in either of the two requests</span></span></span></p>
<p class="western"><span style="font-family: Calibri, serif;"><span style="font-size: small;"><span lang="en">});</span></span></span></p>
<p>The post <a rel="nofollow" href="http://www.pro-tekconsulting.com/blog/features-of-ecmascript6/">FEATURES OF ECMASCRIPT6</a> appeared first on <a rel="nofollow" href="http://www.pro-tekconsulting.com/blog">Pro-Tek Blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pro-tekconsulting.com/blog/features-of-ecmascript6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
