<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Chenuka Sumanasekara on Medium]]></title>
        <description><![CDATA[Stories by Chenuka Sumanasekara on Medium]]></description>
        <link>https://medium.com/@chenukas?source=rss-b0dcb01054b9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*WZ5hID4nHEyGuW5DCBe3dg.jpeg</url>
            <title>Stories by Chenuka Sumanasekara on Medium</title>
            <link>https://medium.com/@chenukas?source=rss-b0dcb01054b9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 18:20:49 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@chenukas/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Most Common JavaScript Array Methods]]></title>
            <link>https://chenukas.medium.com/most-common-javascript-array-methods-a6083feb5b21?source=rss-b0dcb01054b9------2</link>
            <guid isPermaLink="false">https://medium.com/p/a6083feb5b21</guid>
            <category><![CDATA[array-methods]]></category>
            <category><![CDATA[arrays]]></category>
            <category><![CDATA[js]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Chenuka Sumanasekara]]></dc:creator>
            <pubDate>Thu, 08 Apr 2021 18:48:42 GMT</pubDate>
            <atom:updated>2021-04-08T18:48:42.165Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KsVZT2kWuXWaXWe5-v6MLQ.jpeg" /></figure><p>In JavaScript, Array is a single variable that is used to store different elements. Basically there are two ways to declare an array in JavaScript.</p><pre>var cars = [];<br>var cars = new array();</pre><p>In this article, I am going to mention mostly common array methods used in JavaScript.</p><h4>concat()</h4><p>This method is used to merge two or more arrays. This doesn’t modify the existing array, but returns a new array.</p><pre>const arr1 = [&#39;Lamborghini&#39;, &#39;Audi&#39;, &#39;Mercedes-Benz&#39;];<br>const arr2 = [&#39;Ford&#39;, &#39;Toyota&#39;];<br>const cars = arr1.concat(arr2);</pre><pre>console.log(cars);<br>//output: [&#39;Lamborghini&#39;, &#39;Audi&#39;, &#39;Mercedes-Benz&#39;, &#39;Ford&#39;, &#39;Toyota&#39;]</pre><h4>filter()</h4><p>This method creates a new array with all elements that pass the test implemented by the provided function.</p><pre>const cars = [&#39;Lamborghini&#39;, &#39;Audi&#39;, &#39;Mercedes-Benz&#39;, &#39;Ford&#39;, &#39;Toyota&#39;];</pre><pre>const result = cars.filter(car =&gt; car.length &lt; 5);</pre><pre>console.log(result);<br>//output: [&#39;Audi&#39;, &#39;Ford&#39;]</pre><h4>find()</h4><p>This method returns the value of the first element in the provided array that satisfies the provided testing function.</p><pre>const cars = [&#39;Lamborghini&#39;, &#39;Audi&#39;, &#39;Mercedes-Benz&#39;, &#39;Ford&#39;, &#39;Toyota&#39;];</pre><pre>const result = cars.find(car =&gt; car.length &lt; 5);</pre><pre>console.log(result);<br>//output: &#39;Audi&#39;</pre><h4>forEach()</h4><p>This method executes a provided function once for each array element.</p><pre>const cars = [&#39;Lamborghini&#39;, &#39;Audi&#39;, &#39;Mercedes-Benz&#39;, &#39;Ford&#39;, &#39;Toyota&#39;];</pre><pre>cars.forEach(car =&gt; console.log(car));</pre><pre>//output: &#39;Lamborghini&#39;<br>//output: &#39;Audi&#39;<br>//output: &#39;Mercedes-Benz&#39;<br>//output: &#39;Ford&#39;<br>//output: &#39;Toyota&#39;</pre><h4>includes()</h4><p>This method determines whether an array includes a certain value among its entries, and returns true or false.</p><pre>const cars = [&#39;Lamborghini&#39;, &#39;Audi&#39;, &#39;Mercedes-Benz&#39;, &#39;Ford&#39;, &#39;Toyota&#39;];</pre><pre>console.log(cars.includes(&#39;Ford&#39;));<br>//output: true<br>console.log(cars.includes(&#39;Bugatti&#39;));<br>//output: false</pre><h4>indexOf()</h4><p>This method returns the first index at which a given element can be found in the array, or -1 if it is not present.</p><pre>const cars = [&#39;Lamborghini&#39;, &#39;Audi&#39;, &#39;Mercedes-Benz&#39;, &#39;Ford&#39;, &#39;Toyota&#39;];</pre><pre>console.log(cars.indexOf(&#39;Lamborghini&#39;));<br>//output: 0<br>console.log(cars.indexOf(&#39;Bugatti&#39;));<br>//output: -1</pre><h4>map()</h4><p>This method creates a new array populated with the results of calling a provided function on every element in the calling array.</p><pre>const arr = [1, 2, 3, 4, 5];</pre><pre>const result = arr.map(e =&gt; e * 5);</pre><pre>console.log(result);<br>//output: [5, 10, 15, 20, 25]</pre><h4>pop()</h4><p>This method removes the last element from an array and returns that element.</p><pre>const cars = [&#39;Lamborghini&#39;, &#39;Audi&#39;, &#39;Mercedes-Benz&#39;, &#39;Ford&#39;, &#39;Toyota&#39;];</pre><pre>console.log(cars.pop());<br>//output: &#39;Toyota&#39;</pre><pre>console.log(cars);<br>//output: [&#39;Lamborghini&#39;, &#39;Audi&#39;, &#39;Mercedes-Benz&#39;, &#39;Ford&#39;]</pre><h4>push()</h4><p>This method adds one or more elements to the end of an array and returns the new length of the array.</p><pre>const cars = [&#39;Lamborghini&#39;, &#39;Audi&#39;, &#39;Mercedes-Benz&#39;, &#39;Ford&#39;, &#39;Toyota&#39;];</pre><pre>console.log(cars.push(&#39;Bugatti&#39;));<br>//output: 6<br>console.log(cars);<br>//output: [&#39;Lamborghini&#39;, &#39;Audi&#39;, &#39;Mercedes-Benz&#39;, &#39;Ford&#39;, &#39;Toyota&#39;, &#39;Bugatti&#39;]</pre><h4>reverse()</h4><p>This method reverses an array in place . The first array element becomes the last, and the last array element becomes the first.</p><pre>const cars = [&#39;Lamborghini&#39;, &#39;Audi&#39;, &#39;Mercedes-Benz&#39;, &#39;Ford&#39;, &#39;Toyota&#39;];</pre><pre>console.log(cars.reverse());<br>//output: [&#39;Toyota&#39;, &#39;Ford&#39;, &#39;Mercedes-Benz&#39;, &#39;Audi&#39;, &#39;Lamborghini&#39;]</pre><h4>shift()</h4><p>This method removes the first element from an array and returns that removed element.</p><pre>const cars = [&#39;Lamborghini&#39;, &#39;Audi&#39;, &#39;Mercedes-Benz&#39;, &#39;Ford&#39;, &#39;Toyota&#39;];</pre><pre>console.log(cars.shift());<br>//output: &#39;Lamborghini&#39;</pre><pre>console.log(cars);<br>//output: [&#39;Audi&#39;, &#39;Mercedes-Benz&#39;, &#39;Ford&#39;, &#39;Toyota&#39;]</pre><h4>sort()</h4><p>This method sorts the elements of an array in place as ascending and returns the sorted array.</p><pre>const cars = [&#39;Lamborghini&#39;, &#39;Audi&#39;, &#39;Mercedes-Benz&#39;, &#39;Ford&#39;, &#39;Toyota&#39;];<br>cars.sort()<br>console.log(cars);<br>//output: [&#39;Audi&#39;, &#39;Ford&#39;, &#39;Lamborghini&#39;, &#39;Mercedes-Benz&#39;, &#39;Toyota&#39;]</pre><p>In this article, I’ve briefly mentioned mostly used array methods in JavaScript and there are some more methods which helps to manipulate data in arrays. You can refer them by visiting,</p><p><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array">Array - JavaScript | MDN</a></p><p>Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a6083feb5b21" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ES5 vs. ES6 in JavaScript]]></title>
            <link>https://medium.com/sliit-foss/es5-vs-es6-in-javascript-cb10f5fd600c?source=rss-b0dcb01054b9------2</link>
            <guid isPermaLink="false">https://medium.com/p/cb10f5fd600c</guid>
            <category><![CDATA[es6]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[es5-vs-es6]]></category>
            <category><![CDATA[difference]]></category>
            <category><![CDATA[es5]]></category>
            <dc:creator><![CDATA[Chenuka Sumanasekara]]></dc:creator>
            <pubDate>Fri, 19 Mar 2021 17:48:57 GMT</pubDate>
            <atom:updated>2021-03-22T14:33:33.469Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a_oJmKKPLXy8yYxSlYBNYg.jpeg" /></figure><p>Each programming language has its own standardize way of writing code. And JavaScript follows both ES5 and ES6. Whether it is ECMAScript 5(ES5) or ECMAScript 6(ES6), it is a standard for scripting languages like JavaScript, JScript etc. When writing a JavaScript code using these standards, there are slight differences between ES5 and ES6.</p><p>In this article, I am going to explain these differences with the examples.</p><h4><strong>Variables</strong></h4><p>In ES5, there is a one way of defining variables using <strong>var </strong>keyword. But ES6 has introduced two more ways of defining variables using keywords <strong>let</strong> and <strong>const</strong>. However, let and const use block scope while var uses function scope. Also, the variables that are defined using const are immutable.</p><pre>//ES5<br>var age = 20;</pre><pre>//ES6<br>let days = 5;<br>const pi = 3; //immutable</pre><h4>Define Objects</h4><p>ES6 provides easy way to define objects when the keys and the variable names are same.</p><pre>var fullName = &#39;John Moore&#39;;<br>var age = 25;<br>var gender = &#39;Male&#39;;<br>var city = &#39;London&#39;</pre><pre><em>// ES5<br></em>var student = { fullName: fullName, age: age, gender: gender, city: city };</pre><pre><em>// ES6<br></em>var student = { fullName, age, gender, city };</pre><h4><strong>Merge Objects</strong></h4><p>In ES5, <strong>Object.assign()</strong> method is used to merge objects. But ES6 has introduced <strong>spread operator(…) </strong>to merge objects. But there is a slight difference. The Object.assign() changes the target variable, while the spread operator does not.</p><pre>var target = { firstName: &#39;John&#39;, age: 25 }<br>var source = { fullName: &#39;John Moore&#39;, gender: &#39;Male&#39;, city: &#39;London&#39; }</pre><pre>//ES5<br>var updatedTarget = Object.assign(target, source); //changes the target variable</pre><pre>//ES6<br>var updatedTarget = { ...target, ...source};</pre><h4>Object Destructuring</h4><p>In ES5, Objects are extracted one by one manually. But ES6 has made it to one line of code.</p><pre>var student = { fullName: &#39;John Moore&#39;, age: 25, gender: &#39;Male&#39;, city: &#39;London&#39; };</pre><pre>//ES5<br>var fullName = student.fullName;<br>var age = student.age;<br>var gender = student.gender;<br>var city = student.city;</pre><pre>//ES6<br>var { fullName, age, gender, city } = student;</pre><h4>String Interpolation</h4><p>In ES5, <strong>Concatenation operator</strong> is used to join strings. But ES6 has introduced <strong>Template Literal(`) </strong>which allows to perform the string interpolation in convenient way.</p><pre>var fullName = &#39;John Moore&#39;;<br>var age = 25;<br>var gender = &#39;Male&#39;;<br>var city = &#39;London&#39;</pre><pre>//ES5<br>var intro = &#39;Hello, I am &#39; + fullName + &#39;. I am &#39; + age + &#39; years old &#39; + gender + &#39; student from &#39; + city + &#39;.&#39;;</pre><pre>//ES6<br>var intro = `Hello, I am ${fullName}. I am ${age} years old ${gender} student from ${city}.`;</pre><h4>Import Module</h4><p>ES5 uses <strong>require</strong> keyword while ES6 uses <strong>import</strong> keyword. ES6 allows to import child modules as well.</p><pre>//ES5<br>var App = require(&#39;./App&#39;);</pre><pre>//ES6<br>import App from &#39;./App&#39;;<br>import { Header, Sticky } from &#39;@primer/components&#39;; //child modules</pre><h4>Export Module</h4><p>ES6 allows to export child modules and variables as well.</p><pre>var Student = { fullName: &#39;John Moore&#39;, age: 25, gender: &#39;Male&#39;, city: &#39;London&#39; };</pre><pre>//ES5<br>module.exports = Student;</pre><pre>//ES6<br>export default Student;<br>export const fullName = &#39;John Moore&#39;; //child variables<br>export const age = 25;</pre><h4>Arrow Function</h4><p>ES6 has introduced the arrow function. It does not require the keyword <strong>function</strong>.</p><pre>//ES5<br>function sayHello(name) {<br> console.log(&#39;Hello, &#39; + name);<br>}</pre><pre>//ES6<br>const sayHello = (name) =&gt; {<br> console.log(`Hello, ${name}`);<br>}<br>const sayHello = name =&gt; console.log(`Hello, ${name}`); //You can ignore parenthesis, if the function contains a single parameter and only one statement</pre><h4>Promise and Callback</h4><p>ES6 has introduced <strong>Promise()</strong> which is a convenient way of handling callbacks.</p><pre>//ES5<br>var access = true;<br>function callback(message) {<br> console.log(&#39;Success! &#39; + message);<br>}<br>function errorCallback(message) {<br> console.log(&#39;Failed! &#39; + message);<br>}<br>function authenticate(callback, errorCallback) {<br> if (access) {<br>  callback(&#39;You have access.&#39;);<br> } else {<br>  errorCallback(&#39;You don&#39;t have access.&#39;);<br> }<br>}</pre><pre>//ES6<br>var access = true;<br>function authenticate() {<br> return new Promise((resolve, reject) =&gt; {<br>  if (access) {<br>   resolve(&#39;You have access.&#39;);<br>  } else {<br>   reject(&#39;You don&#39;t have access.&#39;);<br>  }<br> });<br>}<br>authenticate().then((message) =&gt; console.log(`Success! ${message}`)).catch((message) =&gt; console.log(`Failed! ${message}`));</pre><p>TA DA… That’s all about differences between ES5 and ES6 in JavaScript.</p><p>Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cb10f5fd600c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/sliit-foss/es5-vs-es6-in-javascript-cb10f5fd600c">ES5 vs. ES6 in JavaScript</a> was originally published in <a href="https://medium.com/sliit-foss">SLIIT FOSS Community</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Your first project with React Native]]></title>
            <link>https://medium.com/sliit-foss/your-first-project-with-react-native-f939b7fbb705?source=rss-b0dcb01054b9------2</link>
            <guid isPermaLink="false">https://medium.com/p/f939b7fbb705</guid>
            <category><![CDATA[react-native-development]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[react-native-app]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[react-native-start]]></category>
            <dc:creator><![CDATA[Chenuka Sumanasekara]]></dc:creator>
            <pubDate>Tue, 02 Mar 2021 15:42:03 GMT</pubDate>
            <atom:updated>2021-03-03T09:21:48.744Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nkVd-nUTTW_uTCTMBxBYBA.jpeg" /></figure><p>React Native has become the most popular cross-platform mobile application development framework which is developed and maintained by Facebook.</p><p>In this article, I am going to divide this topic to three main sections such as,</p><ol><li>Why React Native?</li><li>Prerequisites and environment setup</li><li>Initializing your first project</li></ol><p>Let’s dig into the topic.</p><h4>Why React Native?</h4><p>React Native is a cross-platform mobile application development framework which can be used to develop mobile apps for Android as well as iOS, using React with native technologies.</p><p>Since it creates platform-specific versions of components, a single codebase which is written using JavaScript, can be shared across Android as well as iOS. With a fair knowledge of JavaScript and understanding of native technologies, anyone can start building mobile apps using React Native.</p><h4>Prerequisites and environment setup</h4><p>Before you start the journey with React Native, you have to install and configure some cli-s. You can either use <strong>npm</strong> or <strong>yarn</strong> as your package manager for the project. Since <strong>npm</strong> is bundled with Node.js, you can download and install Node.js. And <strong>yarn</strong> is recommended to install through npm. You can download Node.js via this,</p><p><a href="https://nodejs.org/en/download/">Node.js - Download Node.js®</a></p><p>To install <strong>yarn</strong> package manager, type the below code in your terminal.</p><pre>npm install --global yarn</pre><p>After that, you need to have an Integrated Development Environment(IDE). Here, I will mention my personal preferences, but you can find which is suitable for you by a simple Google search. I personally recommend Visual Studio Code and WebStorm.</p><p>To download Visual Studio Code,</p><p><a href="https://code.visualstudio.com/download">Download Visual Studio Code - Mac, Linux, Windows</a></p><p>To download WebStorm,</p><p><a href="https://www.jetbrains.com/webstorm/download/#section=windows">Download WebStorm: The Smartest JavaScript IDE by JetBrains</a></p><p>After installing your IDE, you have to setup the environment for the React Native project. You can either use Expo CLI or React Native CLI to build your React Native project.</p><p>If you are completely new to mobile app development, it is easy to use Expo CLI, because it runs your project on emulator or mobile(both Android/iOS) within few steps.</p><blockquote>Install Expo CLI</blockquote><p>You can install that using <strong>npm</strong>. Type,</p><pre>npm install -g expo-cli</pre><blockquote>Configuring React Native CLI</blockquote><p><em>Note: You don’t need to install React Native CLI, you can globally access all the react-native commands using </em><strong><em>npx</em></strong><em> prefix.</em></p><p>But build projects with React Native CLI, you have to do some more additional configurations.</p><p>First you need to install Java SE Development Kit(JDK) 8 or higher. You can download that using below link,</p><p><a href="https://www.oracle.com/java/technologies/java-se-glance.html">Java SE</a></p><p>After that you have to install Android Studio with Android SDK, Android SDK Platform, Android Virtual Device, Performance (Intel HAXM) . Finally you have to set environment variables for Java as well as Android SDK. Also you have to add the path of platform-tools to the environment variables.</p><h4>Initializing your first project</h4><blockquote>Using Expo CLI</blockquote><p>To initialize your first project in React Native using Expo CLI, simply type,</p><pre>expo init myFirstProject</pre><p>To run this project,</p><pre>//First, navigate to project folder<br>cd myFirstProject</pre><pre>//Then<br>expo start</pre><pre>//Also, you can use<br>npm start<br>//or<br>yarn start</pre><p><em>Note: It’s required to open android emulator or connect android device to PC, before you run the project. Also you can use </em><strong><em>Expo Go</em></strong><em> on your mobile(both iOS and Android) to scan the QR code and connect to the metro server to see the output of your code.</em></p><blockquote>Using React Native CLI</blockquote><p><em>Note: It’s mandatory to have macOS to build apps for iOS using React Native CLI.</em></p><p>To initialize your first project in React Native using React Native CLI, type,</p><pre>npx react-native init myFirstProject</pre><p>After that, create local.properties file inside myFirstProject/android .</p><pre>## This file must *NOT* be checked into Version Control Systems,<br># as it contains information specific to your local configuration.<br>#<br># Location of the SDK. This is only used by Gradle.<br># For customization when using a Version Control System, please read the<br># header note.<br>#Thu Sep 24 13:04:50 IST 2020<br>sdk.dir=C\:\\Users\\Chenuka\\AppData\\Local\\Android\\Sdk</pre><pre>//Replace the directory path with your Sdk path. </pre><p>Finally, you can run the project using,</p><pre>npx react-native run-android</pre><p><em>Note: It’s required to open android emulator or connect android device to PC, before you run the project.</em></p><p>TA DA… That’s all what you need to begin your journey with React Native.</p><p>Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f939b7fbb705" width="1" height="1" alt=""><hr><p><a href="https://medium.com/sliit-foss/your-first-project-with-react-native-f939b7fbb705">Your first project with React Native</a> was originally published in <a href="https://medium.com/sliit-foss">SLIIT FOSS Community</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>