{"id":484,"date":"2018-07-08T03:21:25","date_gmt":"2018-07-08T03:21:25","guid":{"rendered":"https:\/\/blog.hassler.ec\/wp\/?p=484"},"modified":"2018-06-23T03:38:13","modified_gmt":"2018-06-23T03:38:13","slug":"javascript-fundamentals","status":"publish","type":"post","link":"https:\/\/blog.hassler.ec\/wp\/2018\/07\/08\/javascript-fundamentals\/","title":{"rendered":"Javascript Fundamentals"},"content":{"rendered":"<p id=\"fb7d\" class=\"graf graf--p graf-after--h3\">Javascript (JS) is a scripting languages, primarily used on the Web. It is used to enhance HTML pages and is commonly found embedded in HTML code.<\/p>\n<p id=\"215e\" class=\"graf graf--p graf-after--p\">JavaScript renders web pages in an interactive and dynamic fashion. This allowing the pages to react to events, exhibit special effects, accept variable text, validate data, create cookies, detect a user\u2019s browser, etc.<\/p>\n<figure id=\"a9c4\" class=\"graf graf--figure graf-after--p\">\n<div class=\"aspectRatioPlaceholder is-locked\">\n<div class=\"aspectRatioPlaceholder-fill\"><\/div>\n<div class=\"progressiveMedia js-progressiveMedia graf-image is-canvasLoaded is-imageLoaded\" data-image-id=\"1*4skjRZfCyYbNqOndPYOtvw.jpeg\" data-width=\"796\" data-height=\"398\" data-action=\"zoom\" data-action-value=\"1*4skjRZfCyYbNqOndPYOtvw.jpeg\" data-scroll=\"native\"><canvas class=\"progressiveMedia-canvas js-progressiveMedia-canvas\" width=\"75\" height=\"37\"><\/canvas><img decoding=\"async\" class=\"progressiveMedia-image js-progressiveMedia-image\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*4skjRZfCyYbNqOndPYOtvw.jpeg\" data-src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*4skjRZfCyYbNqOndPYOtvw.jpeg\" \/><\/div>\n<\/div>\n<\/figure>\n<p id=\"9280\" class=\"graf graf--p graf-after--figure\">Hey guys let\u2019s dive into some core javascript functionality.In this article I will be covering CRUD basics and destructuring.<\/p>\n<h3 id=\"1ceb\" class=\"graf graf--h3 graf-after--p\">CRUD Operations<\/h3>\n<p id=\"3407\" class=\"graf graf--p graf-after--h3\">Let\u2019s discuss the CRUD functionality that is how we create,read,update and delete in arrays and objects.<\/p>\n<h3 id=\"21c3\" class=\"graf graf--h3 graf-after--p\"><strong class=\"markup--strong markup--h3-strong\">1.ARRAYS-<\/strong><\/h3>\n<p id=\"d920\" class=\"graf graf--p graf-after--h3\">These are 2 syntaxes for creating an empty array.<\/p>\n<figure id=\"b1a4\" class=\"graf graf--figure graf-after--p\">\n<div class=\"aspectRatioPlaceholder is-locked\">\n<div class=\"aspectRatioPlaceholder-fill\"><\/div>\n<p><img decoding=\"async\" class=\"graf-image\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*OY6nXipWwxzVGvJ4MDI8Bw.png\" data-image-id=\"1*OY6nXipWwxzVGvJ4MDI8Bw.png\" data-width=\"289\" data-height=\"58\" \/><\/p>\n<\/div>\n<\/figure>\n<figure id=\"3620\" class=\"graf graf--figure graf-after--figure\">\n<div class=\"aspectRatioPlaceholder is-locked\">\n<div class=\"aspectRatioPlaceholder-fill\"><\/div>\n<p><img decoding=\"async\" class=\"graf-image\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*6-viDnWSAEIFMmIBN3r3oA.png\" data-image-id=\"1*6-viDnWSAEIFMmIBN3r3oA.png\" data-width=\"427\" data-height=\"38\" \/><\/p>\n<\/div>\n<\/figure>\n<p id=\"dbea\" class=\"graf graf--p graf-after--figure\">In the above statement we have both declared and assigned values in a single statement.<\/p>\n<p id=\"9404\" class=\"graf graf--p graf-after--p\"><strong class=\"markup--strong markup--p-strong\">ADDING DATA USING PUSH<\/strong><\/p>\n<figure id=\"b728\" class=\"graf graf--figure graf-after--p\">\n<div class=\"aspectRatioPlaceholder is-locked\">\n<div class=\"aspectRatioPlaceholder-fill\"><\/div>\n<div class=\"progressiveMedia js-progressiveMedia graf-image is-canvasLoaded is-imageLoaded\" data-image-id=\"1*3LSfFpiYWiTWoCAXzz0jkQ.png\" data-width=\"413\" data-height=\"109\" data-scroll=\"native\"><canvas class=\"progressiveMedia-canvas js-progressiveMedia-canvas\" width=\"75\" height=\"17\"><\/canvas><img decoding=\"async\" class=\"progressiveMedia-image js-progressiveMedia-image\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*3LSfFpiYWiTWoCAXzz0jkQ.png\" data-src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*3LSfFpiYWiTWoCAXzz0jkQ.png\" \/><\/div>\n<\/div>\n<\/figure>\n<p id=\"25c9\" class=\"graf graf--p graf-after--figure\">This is the syntax for pushing data into an array- arrayname.push(item).<\/p>\n<p id=\"504c\" class=\"graf graf--p graf-after--p\">When we add data using push then it is added at the\u00a0<strong class=\"markup--strong markup--p-strong\">end<\/strong>.<\/p>\n<p id=\"33c0\" class=\"graf graf--p graf-after--p\"><strong class=\"markup--strong markup--p-strong\">ADDING DATA USING UNSHIFT<\/strong><\/p>\n<figure id=\"a387\" class=\"graf graf--figure graf-after--p\">\n<div class=\"aspectRatioPlaceholder is-locked\">\n<div class=\"aspectRatioPlaceholder-fill\"><\/div>\n<div class=\"progressiveMedia js-progressiveMedia graf-image is-canvasLoaded is-imageLoaded\" data-image-id=\"1*aP-ua-0u8TMjJNkhjGOOnw.png\" data-width=\"477\" data-height=\"115\" data-scroll=\"native\"><canvas class=\"progressiveMedia-canvas js-progressiveMedia-canvas\" width=\"75\" height=\"17\"><\/canvas><img decoding=\"async\" class=\"progressiveMedia-image js-progressiveMedia-image\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*aP-ua-0u8TMjJNkhjGOOnw.png\" data-src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*aP-ua-0u8TMjJNkhjGOOnw.png\" \/><\/div>\n<\/div>\n<\/figure>\n<p id=\"5dfa\" class=\"graf graf--p graf-after--figure\">This is the syntax for shifting data into an array- arrayname.unshift(item).<\/p>\n<p id=\"fe51\" class=\"graf graf--p graf-after--p\">When we add data using unshift then it is added at the beginning since in unshift the all the elements of the array are shifted 1 position towards the right and the first place is assigned to the item.<\/p>\n<figure id=\"01ca\" class=\"graf graf--figure graf-after--p\">\n<div class=\"aspectRatioPlaceholder is-locked\">\n<div class=\"aspectRatioPlaceholder-fill\"><\/div>\n<div class=\"progressiveMedia js-progressiveMedia graf-image is-canvasLoaded is-imageLoaded\" data-image-id=\"1*dqL-rhP7pXjBlLoDJv8Oow.png\" data-width=\"533\" data-height=\"142\" data-scroll=\"native\"><canvas class=\"progressiveMedia-canvas js-progressiveMedia-canvas\" width=\"75\" height=\"17\"><\/canvas><img decoding=\"async\" class=\"progressiveMedia-image js-progressiveMedia-image\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*dqL-rhP7pXjBlLoDJv8Oow.png\" data-src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*dqL-rhP7pXjBlLoDJv8Oow.png\" \/><\/div>\n<\/div>\n<\/figure>\n<p id=\"0498\" class=\"graf graf--p graf-after--figure\">In the above example mutiple elements are added into the array using push and unshift following the syntax- arrayname.push(item1,item2,item3..) or arrayname.unshift(item1,item2,item3\u2026.).<\/p>\n<p id=\"f3de\" class=\"graf graf--p graf-after--p\"><strong class=\"markup--strong markup--p-strong\">DELETING ELEMENTS USING POP<\/strong><\/p>\n<figure id=\"62ee\" class=\"graf graf--figure graf-after--p\">\n<div class=\"aspectRatioPlaceholder is-locked\">\n<div class=\"aspectRatioPlaceholder-fill\"><\/div>\n<div class=\"progressiveMedia js-progressiveMedia graf-image is-canvasLoaded is-imageLoaded\" data-image-id=\"1*oa7Y_QgrBk8pKPeRMx_uPA.png\" data-width=\"510\" data-height=\"112\" data-scroll=\"native\"><canvas class=\"progressiveMedia-canvas js-progressiveMedia-canvas\" width=\"75\" height=\"15\"><\/canvas><img decoding=\"async\" class=\"progressiveMedia-image js-progressiveMedia-image\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*oa7Y_QgrBk8pKPeRMx_uPA.png\" data-src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*oa7Y_QgrBk8pKPeRMx_uPA.png\" \/><\/div>\n<\/div>\n<\/figure>\n<p id=\"2968\" class=\"graf graf--p graf-after--figure\">This is the syntax for popping element from the array- arrayname.pop().<\/p>\n<p id=\"265a\" class=\"graf graf--p graf-after--p\">When we delete element using pop\u00a0,the element is deleted from the end.<\/p>\n<p id=\"856f\" class=\"graf graf--p graf-after--p\"><strong class=\"markup--strong markup--p-strong\">DELETING ELEMENT USING SHIFT<\/strong><\/p>\n<figure id=\"f366\" class=\"graf graf--figure graf-after--p\">\n<div class=\"aspectRatioPlaceholder is-locked\">\n<div class=\"aspectRatioPlaceholder-fill\"><\/div>\n<div class=\"progressiveMedia js-progressiveMedia graf-image is-canvasLoaded is-imageLoaded\" data-image-id=\"1*zHW6I-JwF4az5fmBYU956A.png\" data-width=\"515\" data-height=\"111\" data-scroll=\"native\"><canvas class=\"progressiveMedia-canvas js-progressiveMedia-canvas\" width=\"75\" height=\"15\"><\/canvas><img decoding=\"async\" class=\"progressiveMedia-image js-progressiveMedia-image\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*zHW6I-JwF4az5fmBYU956A.png\" data-src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*zHW6I-JwF4az5fmBYU956A.png\" \/><\/div>\n<\/div>\n<\/figure>\n<p id=\"8464\" class=\"graf graf--p graf-after--figure\">This is the syntax for shifting element from the array- arrayname.shift().<\/p>\n<p id=\"33be\" class=\"graf graf--p graf-after--p\">When we delete element using shift,the element is deleted from the beginning.<\/p>\n<p id=\"88b7\" class=\"graf graf--p graf-after--p\"><strong class=\"markup--strong markup--p-strong\">ADDING,UPDATING,DELETING ELEMENTS USING SPLICE<\/strong><\/p>\n<figure id=\"1b2f\" class=\"graf graf--figure graf-after--p\">\n<div class=\"aspectRatioPlaceholder is-locked\">\n<div class=\"aspectRatioPlaceholder-fill\"><\/div>\n<p><img decoding=\"async\" class=\"graf-image\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*Ynig70ouOS0aN7BGOJvx2Q.png\" data-image-id=\"1*Ynig70ouOS0aN7BGOJvx2Q.png\" data-width=\"525\" data-height=\"41\" \/><\/p>\n<\/div>\n<\/figure>\n<p id=\"0ef0\" class=\"graf graf--p graf-after--figure\">Here index denotes the position,removes the number of elements specified in deletecount and then inserts the elements present from elem1 to elemN.<\/p>\n<p id=\"1202\" class=\"graf graf--p graf-after--p\">EXAMPLE 1- DELETION<\/p>\n<figure id=\"7211\" class=\"graf graf--figure graf-after--p\">\n<div class=\"aspectRatioPlaceholder is-locked\">\n<div class=\"aspectRatioPlaceholder-fill\"><\/div>\n<div class=\"progressiveMedia js-progressiveMedia graf-image is-canvasLoaded is-imageLoaded\" data-image-id=\"1*LTRLm8SBOFYZcoObDkwBQg.png\" data-width=\"460\" data-height=\"115\" data-scroll=\"native\"><canvas class=\"progressiveMedia-canvas js-progressiveMedia-canvas\" width=\"75\" height=\"17\"><\/canvas><img decoding=\"async\" class=\"progressiveMedia-image js-progressiveMedia-image\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*LTRLm8SBOFYZcoObDkwBQg.png\" data-src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*LTRLm8SBOFYZcoObDkwBQg.png\" \/><\/div>\n<\/div>\n<\/figure>\n<p id=\"dc48\" class=\"graf graf--p graf-after--figure\">Here from index 1\u00a0, 1 element is to be deleted.<\/p>\n<p id=\"7042\" class=\"graf graf--p graf-after--p\">EXAMPLE 2-DELETION AND INSERTION<\/p>\n<figure id=\"57f0\" class=\"graf graf--figure graf-after--p\">\n<div class=\"aspectRatioPlaceholder is-locked\">\n<div class=\"aspectRatioPlaceholder-fill\"><\/div>\n<div class=\"progressiveMedia js-progressiveMedia graf-image is-canvasLoaded is-imageLoaded\" data-image-id=\"1*939ZLMV7TTS6KKHe7fxlRA.png\" data-width=\"508\" data-height=\"132\" data-scroll=\"native\"><canvas class=\"progressiveMedia-canvas js-progressiveMedia-canvas\" width=\"75\" height=\"17\"><\/canvas><img decoding=\"async\" class=\"progressiveMedia-image js-progressiveMedia-image\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*939ZLMV7TTS6KKHe7fxlRA.png\" data-src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*939ZLMV7TTS6KKHe7fxlRA.png\" \/><\/div>\n<\/div>\n<\/figure>\n<p id=\"5e9e\" class=\"graf graf--p graf-after--figure\">Here from index 0, 3 elements are to be deleted and 2 items lets and dance have to be added.So the final array looks like that.If we try to return the splice it returns the array of removed elements.<\/p>\n<p id=\"b5aa\" class=\"graf graf--p graf-after--p\">EXAMPLE 3\u2013INSERTION<\/p>\n<figure id=\"c03a\" class=\"graf graf--figure graf-after--p\">\n<div class=\"aspectRatioPlaceholder is-locked\">\n<div class=\"aspectRatioPlaceholder-fill\"><\/div>\n<div class=\"progressiveMedia js-progressiveMedia graf-image is-canvasLoaded is-imageLoaded\" data-image-id=\"1*nmWP12K2O4CqiMch96FQww.png\" data-width=\"569\" data-height=\"160\" data-scroll=\"native\"><canvas class=\"progressiveMedia-canvas js-progressiveMedia-canvas\" width=\"75\" height=\"20\"><\/canvas><img decoding=\"async\" class=\"progressiveMedia-image js-progressiveMedia-image\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*nmWP12K2O4CqiMch96FQww.png\" data-src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*nmWP12K2O4CqiMch96FQww.png\" \/><\/div>\n<\/div>\n<\/figure>\n<p id=\"2a08\" class=\"graf graf--p graf-after--figure\">Here the deletecount is mentioned as 0 and from index 2 two items complex and language are added.<\/p>\n<p id=\"3b02\" class=\"graf graf--p graf-after--p\"><strong class=\"markup--strong markup--p-strong\">MAKING SUBARRAYS USING SLICE<\/strong><\/p>\n<figure id=\"b469\" class=\"graf graf--figure graf-after--p\">\n<div class=\"aspectRatioPlaceholder is-locked\">\n<div class=\"aspectRatioPlaceholder-fill\"><\/div>\n<p><img decoding=\"async\" class=\"graf-image\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*piaIHZz-loep0HpsyDuBeA.png\" data-image-id=\"1*piaIHZz-loep0HpsyDuBeA.png\" data-width=\"277\" data-height=\"45\" \/><\/p>\n<\/div>\n<\/figure>\n<p id=\"3c1c\" class=\"graf graf--p graf-after--figure\">Here start denotes the position where you want to start and end denotes the index where you want the end.So accordint to the start and end indexes specified the slice function reutrn a copy of the array from start to end but not including end.<\/p>\n<figure id=\"c228\" class=\"graf graf--figure graf-after--p\">\n<div class=\"aspectRatioPlaceholder is-locked\">\n<div class=\"aspectRatioPlaceholder-fill\"><\/div>\n<div class=\"progressiveMedia js-progressiveMedia graf-image is-canvasLoaded is-imageLoaded\" data-image-id=\"1*9FjFdO_ZrXDLuT_TdRR_Qg.png\" data-width=\"434\" data-height=\"160\" data-scroll=\"native\"><canvas class=\"progressiveMedia-canvas js-progressiveMedia-canvas\" width=\"75\" height=\"27\"><\/canvas><img decoding=\"async\" class=\"progressiveMedia-image js-progressiveMedia-image\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*9FjFdO_ZrXDLuT_TdRR_Qg.png\" data-src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*9FjFdO_ZrXDLuT_TdRR_Qg.png\" \/><\/div>\n<\/div>\n<\/figure>\n<p id=\"360a\" class=\"graf graf--p graf-after--figure\"><strong class=\"markup--strong markup--p-strong\">JOIN ARRAYS WITH ITEMS OR ARRAYS USING CONCAT<\/strong><\/p>\n<figure id=\"492e\" class=\"graf graf--figure graf-after--p\">\n<div class=\"aspectRatioPlaceholder is-locked\">\n<div class=\"aspectRatioPlaceholder-fill\"><\/div>\n<p><img decoding=\"async\" class=\"graf-image\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*b214s8dTgSssSmxpVoKKWg.png\" data-image-id=\"1*b214s8dTgSssSmxpVoKKWg.png\" data-width=\"319\" data-height=\"41\" \/><\/p>\n<\/div>\n<\/figure>\n<p id=\"708e\" class=\"graf graf--p graf-after--figure\">Concat returns new array merging arrays with the arguments which maybe items or other arrays.<\/p>\n<figure id=\"7af9\" class=\"graf graf--figure graf-after--p\">\n<div class=\"aspectRatioPlaceholder is-locked\">\n<div class=\"aspectRatioPlaceholder-fill\"><\/div>\n<div class=\"progressiveMedia js-progressiveMedia graf-image is-canvasLoaded is-imageLoaded\" data-image-id=\"1*VZqumfM8VnBElzo_Qlim-Q.png\" data-width=\"494\" data-height=\"197\" data-scroll=\"native\"><canvas class=\"progressiveMedia-canvas js-progressiveMedia-canvas\" width=\"75\" height=\"27\"><\/canvas><img decoding=\"async\" class=\"progressiveMedia-image js-progressiveMedia-image\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*VZqumfM8VnBElzo_Qlim-Q.png\" data-src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*VZqumfM8VnBElzo_Qlim-Q.png\" \/><\/div>\n<\/div>\n<\/figure>\n<p id=\"adc9\" class=\"graf graf--p graf-after--figure\"><strong class=\"markup--strong markup--p-strong\">SEARCHING<\/strong><\/p>\n<p id=\"b08e\" class=\"graf graf--p graf-after--p\">The methods are similar to the ones used for strings but work on items instead of characters.<\/p>\n<figure id=\"07f4\" class=\"graf graf--figure graf-after--p\">\n<div class=\"aspectRatioPlaceholder is-locked\">\n<div class=\"aspectRatioPlaceholder-fill\"><\/div>\n<div class=\"progressiveMedia js-progressiveMedia graf-image is-canvasLoaded is-imageLoaded\" data-image-id=\"1*MuZwjpPHVZj-5p21Yy7YMA.png\" data-width=\"844\" data-height=\"121\" data-action=\"zoom\" data-action-value=\"1*MuZwjpPHVZj-5p21Yy7YMA.png\" data-scroll=\"native\"><canvas class=\"progressiveMedia-canvas js-progressiveMedia-canvas\" width=\"75\" height=\"10\"><\/canvas><img decoding=\"async\" class=\"progressiveMedia-image js-progressiveMedia-image\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*MuZwjpPHVZj-5p21Yy7YMA.png\" data-src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*MuZwjpPHVZj-5p21Yy7YMA.png\" \/><\/div>\n<\/div>\n<\/figure>\n<figure id=\"978b\" class=\"graf graf--figure graf-after--figure\">\n<div class=\"aspectRatioPlaceholder is-locked\">\n<div class=\"aspectRatioPlaceholder-fill\"><\/div>\n<div class=\"progressiveMedia js-progressiveMedia graf-image is-canvasLoaded is-imageLoaded\" data-image-id=\"1*y0LpS2hTP8TpBNN0bWcOzw.png\" data-width=\"407\" data-height=\"143\" data-scroll=\"native\"><canvas class=\"progressiveMedia-canvas js-progressiveMedia-canvas\" width=\"75\" height=\"25\"><\/canvas><img decoding=\"async\" class=\"progressiveMedia-image js-progressiveMedia-image\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*y0LpS2hTP8TpBNN0bWcOzw.png\" data-src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*y0LpS2hTP8TpBNN0bWcOzw.png\" \/><\/div>\n<\/div>\n<\/figure>\n<p id=\"c8f9\" class=\"graf graf--p graf-after--figure\">These methods use === for comparison.<\/p>\n<p id=\"55be\" class=\"graf graf--p graf-after--p\">If we just want to know if the array contains the item then we use includes.Also includes can handle NaN correctly unlike indexOf and lastIndexOf.<\/p>\n<p id=\"bc21\" class=\"graf graf--p graf-after--p\">FIND AND FIND INDEX<\/p>\n<figure id=\"981a\" class=\"graf graf--figure graf-after--p\">\n<div class=\"aspectRatioPlaceholder is-locked\">\n<div class=\"aspectRatioPlaceholder-fill\"><\/div>\n<p><img decoding=\"async\" class=\"graf-image\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*J1Wlk8zfIRgXqPlh9Ck0Cg.png\" data-image-id=\"1*J1Wlk8zfIRgXqPlh9Ck0Cg.png\" data-width=\"540\" data-height=\"70\" \/><\/p>\n<\/div>\n<\/figure>\n<p id=\"e279\" class=\"graf graf--p graf-after--figure\">The syntax is mentioned above and returns the item if it finds it or if nothing is found then undefined is returned.<\/p>\n<figure id=\"a427\" class=\"graf graf--figure graf-after--p\">\n<div class=\"aspectRatioPlaceholder is-locked\">\n<div class=\"aspectRatioPlaceholder-fill\"><\/div>\n<div class=\"progressiveMedia js-progressiveMedia graf-image is-canvasLoaded is-imageLoaded\" data-image-id=\"1*o5fUIhvzivdU9fLk_X7WQQ.png\" data-width=\"425\" data-height=\"173\" data-scroll=\"native\"><canvas class=\"progressiveMedia-canvas js-progressiveMedia-canvas\" width=\"75\" height=\"30\"><\/canvas><img decoding=\"async\" class=\"progressiveMedia-image js-progressiveMedia-image\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*o5fUIhvzivdU9fLk_X7WQQ.png\" data-src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*o5fUIhvzivdU9fLk_X7WQQ.png\" \/><\/div>\n<\/div>\n<\/figure>\n<p id=\"6548\" class=\"graf graf--p graf-after--figure\">Here above we have used the arrow function syntax where item is the argument and we return the item where item.id==1.<\/p>\n<p id=\"a430\" class=\"graf graf--p graf-after--p\">findIndex achieves the same thing but returns the index of the found element instead of the actual item.<\/p>\n<p id=\"5b43\" class=\"graf graf--p graf-after--p\">FILTER<\/p>\n<p id=\"03db\" class=\"graf graf--p graf-after--p\">The filter function works similar to find but instead of returning just the first item it returns all the matching elements.<\/p>\n<figure id=\"6d3a\" class=\"graf graf--figure graf-after--p\">\n<div class=\"aspectRatioPlaceholder is-locked\">\n<div class=\"aspectRatioPlaceholder-fill\"><\/div>\n<p><img decoding=\"async\" class=\"graf-image\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*IM7_dSqgtNydmBvu0haZHA.png\" data-image-id=\"1*IM7_dSqgtNydmBvu0haZHA.png\" data-width=\"547\" data-height=\"74\" \/><\/p>\n<\/div>\n<\/figure>\n<p id=\"94e2\" class=\"graf graf--p graf-after--figure\">Below the example returns all the items where item.id &lt; 3 and follows the arrow function convention.<\/p>\n<figure id=\"d3cd\" class=\"graf graf--figure graf-after--p\">\n<div class=\"aspectRatioPlaceholder is-locked\">\n<div class=\"aspectRatioPlaceholder-fill\"><\/div>\n<div class=\"progressiveMedia js-progressiveMedia graf-image is-canvasLoaded is-imageLoaded\" data-image-id=\"1*Rp3KlTq1dzIQd4HTWWZtlQ.png\" data-width=\"448\" data-height=\"191\" data-scroll=\"native\"><canvas class=\"progressiveMedia-canvas js-progressiveMedia-canvas\" width=\"75\" height=\"30\"><\/canvas><img decoding=\"async\" class=\"progressiveMedia-image js-progressiveMedia-image\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*Rp3KlTq1dzIQd4HTWWZtlQ.png\" data-src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*Rp3KlTq1dzIQd4HTWWZtlQ.png\" \/><\/div>\n<\/div>\n<\/figure>\n<p id=\"9209\" class=\"graf graf--p graf-after--figure\"><strong class=\"markup--strong markup--p-strong\">TRANSFORMING AN ARRAY<\/strong><\/p>\n<p id=\"fc56\" class=\"graf graf--p graf-after--p\">Below there are functions that transform or reorder the array without changing the original array.It is considered to be one of the most important applications so take your time to understand this one.<\/p>\n<p id=\"40a9\" class=\"graf graf--p graf-after--p\">MAP<\/p>\n<figure id=\"8b77\" class=\"graf graf--figure graf-after--p\">\n<div class=\"aspectRatioPlaceholder is-locked\">\n<div class=\"aspectRatioPlaceholder-fill\"><\/div>\n<p><img decoding=\"async\" class=\"graf-image\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*AjKZWyTp-3DUf7ZU1b2RcA.png\" data-image-id=\"1*AjKZWyTp-3DUf7ZU1b2RcA.png\" data-width=\"549\" data-height=\"80\" \/><\/p>\n<\/div>\n<\/figure>\n<p id=\"eaa4\" class=\"graf graf--p graf-after--figure\">Here the result variable returns whatever function is operated on the array without mutating the array.For example below the we have a new array where every entry of the array is converted into its length.<\/p>\n<figure id=\"f832\" class=\"graf graf--figure graf-after--p\">\n<div class=\"aspectRatioPlaceholder is-locked\">\n<div class=\"aspectRatioPlaceholder-fill\"><\/div>\n<p><img decoding=\"async\" class=\"graf-image\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*mwadgGv0Kk4zy2akcwo9cw.png\" data-image-id=\"1*mwadgGv0Kk4zy2akcwo9cw.png\" data-width=\"593\" data-height=\"53\" \/><\/p>\n<\/div>\n<\/figure>\n<p id=\"9485\" class=\"graf graf--p graf-after--figure\">Here we are again following the arrow function convention where item is the argument and each item is transformed into its length.<\/p>\n<p id=\"3f99\" class=\"graf graf--p graf-after--p\">REDUCE<\/p>\n<p id=\"9b5b\" class=\"graf graf--p graf-after--p\">For iterating over an array we may use loops.For transforming the value of each entry we can use maps.But if we want to return a single value based on the the entire array then we use reduce.<\/p>\n<figure id=\"4be1\" class=\"graf graf--figure graf-after--p\">\n<div class=\"aspectRatioPlaceholder is-locked\">\n<div class=\"aspectRatioPlaceholder-fill\"><\/div>\n<p><img decoding=\"async\" class=\"graf-image\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*R1BF1jS3WBa3gh_qYkGsTQ.png\" data-image-id=\"1*R1BF1jS3WBa3gh_qYkGsTQ.png\" data-width=\"634\" data-height=\"73\" \/><\/p>\n<\/div>\n<\/figure>\n<p id=\"cc24\" class=\"graf graf--p graf-after--figure\">Here previousValue means the value it returned in the previous call.Index specifies from where we start applying the function and initial at the end denotes the initial value of previousValue.Let\u2019s see an example to understand this better.<\/p>\n<figure id=\"6a19\" class=\"graf graf--figure graf-after--p\">\n<div class=\"aspectRatioPlaceholder is-locked\">\n<div class=\"aspectRatioPlaceholder-fill\"><\/div>\n<div class=\"progressiveMedia js-progressiveMedia graf-image is-canvasLoaded is-imageLoaded\" data-image-id=\"1*UgyCRqQiudlCC0PGIwsunQ.png\" data-width=\"608\" data-height=\"110\" data-scroll=\"native\"><canvas class=\"progressiveMedia-canvas js-progressiveMedia-canvas\" width=\"75\" height=\"12\"><\/canvas><img decoding=\"async\" class=\"progressiveMedia-image js-progressiveMedia-image\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*UgyCRqQiudlCC0PGIwsunQ.png\" data-src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*UgyCRqQiudlCC0PGIwsunQ.png\" \/><\/div>\n<\/div>\n<\/figure>\n<p id=\"a1b1\" class=\"graf graf--p graf-after--figure\">Here we are using arrow function convention where sum is the previousValue and is assigned initial value of 0.The function returns sum+current in every call and since the index is not specified it covers the entire array.So finally it returns the sum of all the elements in the array.<\/p>\n<h3 id=\"a856\" class=\"graf graf--h3 graf-after--p\"><strong class=\"markup--strong markup--h3-strong\">2.OBJECTS<\/strong><\/h3>\n<p id=\"7bfe\" class=\"graf graf--p graf-after--h3\">This is the syntax to create new objects.<\/p>\n<figure id=\"44c1\" class=\"graf graf--figure graf-after--p\">\n<div class=\"aspectRatioPlaceholder is-locked\">\n<div class=\"aspectRatioPlaceholder-fill\"><\/div>\n<p><img decoding=\"async\" class=\"graf-image\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*nSdD9ItRhp9wmAlTuab37w.png\" data-image-id=\"1*nSdD9ItRhp9wmAlTuab37w.png\" data-width=\"536\" data-height=\"53\" \/><\/p>\n<\/div>\n<\/figure>\n<p id=\"0e60\" class=\"graf graf--p graf-after--figure\">Here, we have created new object with these properties.<\/p>\n<figure id=\"df25\" class=\"graf graf--figure graf-after--p\">\n<div class=\"aspectRatioPlaceholder is-locked\">\n<div class=\"aspectRatioPlaceholder-fill\"><\/div>\n<p><img decoding=\"async\" class=\"graf-image\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*hUPtEdw72HEmECEwQUHVyw.png\" data-image-id=\"1*hUPtEdw72HEmECEwQUHVyw.png\" data-width=\"574\" data-height=\"82\" \/><\/p>\n<\/div>\n<\/figure>\n<p id=\"df44\" class=\"graf graf--p graf-after--figure\">Here,we have added a boolean property.<\/p>\n<figure id=\"f228\" class=\"graf graf--figure graf-after--p\">\n<div class=\"aspectRatioPlaceholder is-locked\">\n<div class=\"aspectRatioPlaceholder-fill\"><\/div>\n<p><img decoding=\"async\" class=\"graf-image\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*irwu9e_1SVew8tbXv1MACg.png\" data-image-id=\"1*irwu9e_1SVew8tbXv1MACg.png\" data-width=\"287\" data-height=\"45\" \/><\/p>\n<\/div>\n<\/figure>\n<p id=\"5e7d\" class=\"graf graf--p graf-after--figure\">Here, we delete this property from the user object.<\/p>\n<figure id=\"ba83\" class=\"graf graf--figure graf-after--p\">\n<div class=\"aspectRatioPlaceholder is-locked\">\n<div class=\"aspectRatioPlaceholder-fill\"><\/div>\n<p><img decoding=\"async\" class=\"graf-image\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*a8JQYzVZT0GzLeIRJORYCA.png\" data-image-id=\"1*a8JQYzVZT0GzLeIRJORYCA.png\" data-width=\"273\" data-height=\"39\" \/><\/p>\n<\/div>\n<\/figure>\n<p id=\"0740\" class=\"graf graf--p graf-after--figure\">Here let\u2019s see how we assign the property values to an object using a function.<\/p>\n<figure id=\"1191\" class=\"graf graf--figure graf-after--p\">\n<div class=\"aspectRatioPlaceholder is-locked\">\n<div class=\"aspectRatioPlaceholder-fill\"><\/div>\n<div class=\"progressiveMedia js-progressiveMedia graf-image is-canvasLoaded is-imageLoaded\" data-image-id=\"1*y0w3rKjYvRPaFVsNseUnvw.png\" data-width=\"367\" data-height=\"188\" data-scroll=\"native\"><canvas class=\"progressiveMedia-canvas js-progressiveMedia-canvas\" width=\"75\" height=\"37\"><\/canvas><img decoding=\"async\" class=\"progressiveMedia-image js-progressiveMedia-image\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*y0w3rKjYvRPaFVsNseUnvw.png\" data-src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*y0w3rKjYvRPaFVsNseUnvw.png\" \/><\/div>\n<\/div>\n<\/figure>\n<p id=\"aeb7\" class=\"graf graf--p graf-after--figure\">Here is the shorthand for the same.Since we are assigning property name to argument name and likewise we can avoid extra syntax and can execute this.<\/p>\n<figure id=\"cbb4\" class=\"graf graf--figure graf-after--p\">\n<div class=\"aspectRatioPlaceholder is-locked\">\n<div class=\"aspectRatioPlaceholder-fill\"><\/div>\n<div class=\"progressiveMedia js-progressiveMedia graf-image is-canvasLoaded is-imageLoaded\" data-image-id=\"1*uwLgyE1dracexBViUsaZLg.png\" data-width=\"453\" data-height=\"130\" data-scroll=\"native\"><canvas class=\"progressiveMedia-canvas js-progressiveMedia-canvas\" width=\"75\" height=\"20\"><\/canvas><img decoding=\"async\" class=\"progressiveMedia-image js-progressiveMedia-image\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*uwLgyE1dracexBViUsaZLg.png\" data-src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*uwLgyE1dracexBViUsaZLg.png\" \/><\/div>\n<\/div>\n<\/figure>\n<p id=\"d474\" class=\"graf graf--p graf-after--figure\">Let\u2019s see how we can access all the key value pairs of the object using for loop.<\/p>\n<figure id=\"aa89\" class=\"graf graf--figure graf-after--p\">\n<div class=\"aspectRatioPlaceholder is-locked\">\n<div class=\"aspectRatioPlaceholder-fill\"><\/div>\n<p><img decoding=\"async\" class=\"graf-image\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*Ecq5cGFI8qyKRqxW_lktyA.png\" data-image-id=\"1*Ecq5cGFI8qyKRqxW_lktyA.png\" data-width=\"608\" data-height=\"67\" \/><\/p>\n<\/div>\n<\/figure>\n<figure id=\"12f2\" class=\"graf graf--figure graf-after--figure\">\n<div class=\"aspectRatioPlaceholder is-locked\">\n<div class=\"aspectRatioPlaceholder-fill\"><\/div>\n<div class=\"progressiveMedia js-progressiveMedia graf-image is-canvasLoaded is-imageLoaded\" data-image-id=\"1*p5lvowuhHSNg2XC5lTMmZQ.png\" data-width=\"434\" data-height=\"216\" data-scroll=\"native\"><canvas class=\"progressiveMedia-canvas js-progressiveMedia-canvas\" width=\"75\" height=\"35\"><\/canvas><img decoding=\"async\" class=\"progressiveMedia-image js-progressiveMedia-image\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*p5lvowuhHSNg2XC5lTMmZQ.png\" data-src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*p5lvowuhHSNg2XC5lTMmZQ.png\" \/><\/div>\n<\/div>\n<\/figure>\n<p id=\"79ba\" class=\"graf graf--p graf-after--figure\"><strong class=\"markup--strong markup--p-strong\">OBJECT METHODS<\/strong><\/p>\n<p id=\"9c3b\" class=\"graf graf--p graf-after--p\">If we have the below mentioned object\u00a0,then let\u2019s see how we can apply object methods to access the keys,values and both(entries).<\/p>\n<figure id=\"1d6f\" class=\"graf graf--figure graf-after--p\">\n<div class=\"aspectRatioPlaceholder is-locked\">\n<div class=\"aspectRatioPlaceholder-fill\"><\/div>\n<p><img decoding=\"async\" class=\"graf-image\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*Mae2UJktgFok18jJGPkOwg.png\" data-image-id=\"1*Mae2UJktgFok18jJGPkOwg.png\" data-width=\"297\" data-height=\"81\" \/><\/p>\n<\/div>\n<\/figure>\n<figure id=\"940c\" class=\"graf graf--figure graf-after--figure\">\n<div class=\"aspectRatioPlaceholder is-locked\">\n<div class=\"aspectRatioPlaceholder-fill\"><\/div>\n<div class=\"progressiveMedia js-progressiveMedia graf-image is-canvasLoaded is-imageLoaded\" data-image-id=\"1*4CZ5G6SD3xDQp2rBTfj4Og.png\" data-width=\"530\" data-height=\"101\" data-scroll=\"native\"><canvas class=\"progressiveMedia-canvas js-progressiveMedia-canvas\" width=\"75\" height=\"12\"><\/canvas><img decoding=\"async\" class=\"progressiveMedia-image js-progressiveMedia-image\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*4CZ5G6SD3xDQp2rBTfj4Og.png\" data-src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*4CZ5G6SD3xDQp2rBTfj4Og.png\" \/><\/div>\n<\/div>\n<\/figure>\n<h3 id=\"31a7\" class=\"graf graf--h3 graf-after--figure\"><strong class=\"markup--strong markup--h3-strong\">3.DESTRUCTURING<\/strong><\/h3>\n<p id=\"5b0e\" class=\"graf graf--p graf-after--h3\"><em class=\"markup--em markup--p-em\">Destructuring assignment<\/em>\u00a0is a special syntax that allows us to \u201cunpack\u201d arrays or objects into a bunch of variables, as sometimes they are more convenient. Destructuring also works great with complex functions that have a lot of parameters, default values, and soon we\u2019ll see how these are handled too.<\/p>\n<p id=\"3427\" class=\"graf graf--p graf-after--p\">Here the array is not modified.<\/p>\n<figure id=\"591b\" class=\"graf graf--figure graf-after--p\">\n<div class=\"aspectRatioPlaceholder is-locked\">\n<div class=\"aspectRatioPlaceholder-fill\"><\/div>\n<div class=\"progressiveMedia js-progressiveMedia graf-image is-canvasLoaded is-imageLoaded\" data-image-id=\"1*j7-31vz8wVog_n658H0Wtg.png\" data-width=\"495\" data-height=\"162\" data-scroll=\"native\"><canvas class=\"progressiveMedia-canvas js-progressiveMedia-canvas\" width=\"75\" height=\"22\"><\/canvas><img decoding=\"async\" class=\"progressiveMedia-image js-progressiveMedia-image\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*j7-31vz8wVog_n658H0Wtg.png\" data-src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*j7-31vz8wVog_n658H0Wtg.png\" \/><\/div>\n<\/div>\n<\/figure>\n<p id=\"612a\" class=\"graf graf--p graf-after--figure\">Here firstname is assigned arr[0] and surname is assigned arr[1].<\/p>\n<figure id=\"8ebe\" class=\"graf graf--figure graf-after--p\">\n<div class=\"aspectRatioPlaceholder is-locked\">\n<div class=\"aspectRatioPlaceholder-fill\"><\/div>\n<p><img decoding=\"async\" class=\"graf-image\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*j9vXIHWt4y_HQs1NBqoczw.png\" data-image-id=\"1*j9vXIHWt4y_HQs1NBqoczw.png\" data-width=\"670\" data-height=\"83\" \/><\/p>\n<\/div>\n<\/figure>\n<p id=\"3566\" class=\"graf graf--p graf-after--figure\">In the above example the first and second elements are skipped by just having commas.<\/p>\n<figure id=\"de76\" class=\"graf graf--figure graf-after--p\">\n<div class=\"aspectRatioPlaceholder is-locked\">\n<div class=\"aspectRatioPlaceholder-fill\"><\/div>\n<p><img decoding=\"async\" class=\"graf-image\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*bEkvpjH5jOugw1TY9KA5rw.png\" data-image-id=\"1*bEkvpjH5jOugw1TY9KA5rw.png\" data-width=\"403\" data-height=\"47\" \/><\/p>\n<\/div>\n<\/figure>\n<p id=\"b0bb\" class=\"graf graf--p graf-after--figure\">The above example shows destructuring is not only limited to arrays but works for all iterables such as strings,sets etc.<\/p>\n<figure id=\"e437\" class=\"graf graf--figure graf-after--p\">\n<div class=\"aspectRatioPlaceholder is-locked\">\n<div class=\"aspectRatioPlaceholder-fill\"><\/div>\n<p><img decoding=\"async\" class=\"graf-image\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*uIL2LuhJKOhAhGRefuP7rg.png\" data-image-id=\"1*uIL2LuhJKOhAhGRefuP7rg.png\" data-width=\"502\" data-height=\"85\" \/><\/p>\n<\/div>\n<\/figure>\n<p id=\"93a9\" class=\"graf graf--p graf-after--figure\">In the above example we are assigning object properties by destructuring.<\/p>\n<figure id=\"dd9e\" class=\"graf graf--figure graf-after--p\">\n<div class=\"aspectRatioPlaceholder is-locked\">\n<div class=\"aspectRatioPlaceholder-fill\"><\/div>\n<div class=\"progressiveMedia js-progressiveMedia graf-image is-canvasLoaded is-imageLoaded\" data-image-id=\"1*SH8m7ewx-1pDP_IxZ90u_w.png\" data-width=\"555\" data-height=\"157\" data-scroll=\"native\"><canvas class=\"progressiveMedia-canvas js-progressiveMedia-canvas\" width=\"75\" height=\"20\"><\/canvas><img decoding=\"async\" class=\"progressiveMedia-image js-progressiveMedia-image\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*SH8m7ewx-1pDP_IxZ90u_w.png\" data-src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*SH8m7ewx-1pDP_IxZ90u_w.png\" \/><\/div>\n<\/div>\n<\/figure>\n<p id=\"3aa5\" class=\"graf graf--p graf-after--figure\">The above example is a good one where we are able to access the key-value pairs from the object using destructuring in a for loop.<\/p>\n<p id=\"47a8\" class=\"graf graf--p graf-after--p\"><strong class=\"markup--strong markup--p-strong\">REST VARIABLES<\/strong><\/p>\n<figure id=\"680d\" class=\"graf graf--figure graf-after--p\">\n<div class=\"aspectRatioPlaceholder is-locked\">\n<div class=\"aspectRatioPlaceholder-fill\"><\/div>\n<div class=\"progressiveMedia js-progressiveMedia graf-image is-canvasLoaded is-imageLoaded\" data-image-id=\"1*Wf9jxO1w6PyVowhP9fWq2A.png\" data-width=\"706\" data-height=\"148\" data-action=\"zoom\" data-action-value=\"1*Wf9jxO1w6PyVowhP9fWq2A.png\" data-scroll=\"native\"><canvas class=\"progressiveMedia-canvas js-progressiveMedia-canvas\" width=\"75\" height=\"15\"><\/canvas><img decoding=\"async\" class=\"progressiveMedia-image js-progressiveMedia-image\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*Wf9jxO1w6PyVowhP9fWq2A.png\" data-src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*Wf9jxO1w6PyVowhP9fWq2A.png\" \/><\/div>\n<\/div>\n<\/figure>\n<p id=\"b8e5\" class=\"graf graf--p graf-after--figure\">In the above example we are accessing the rest variables which implies all the arguments after name2 is pushed into the array rest.<\/p>\n<p id=\"6d5f\" class=\"graf graf--p graf-after--p\"><strong class=\"markup--strong markup--p-strong\">DEFAULT VALUES<\/strong><\/p>\n<figure id=\"8c78\" class=\"graf graf--figure graf-after--p\">\n<div class=\"aspectRatioPlaceholder is-locked\">\n<div class=\"aspectRatioPlaceholder-fill\"><\/div>\n<p><img decoding=\"async\" class=\"graf-image\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*imSx8yaAX2OxJ3Xery99bg.png\" data-image-id=\"1*imSx8yaAX2OxJ3Xery99bg.png\" data-width=\"532\" data-height=\"96\" \/><\/p>\n<\/div>\n<\/figure>\n<p id=\"b98e\" class=\"graf graf--p graf-after--figure\">Here the variables are already assigned default values.This is helpful because on the right side we have only one variable so the second argument would have been assigned undefined but since it has a default value \u201cAnonymous\u201d, we are able to solve this problem.<\/p>\n<p id=\"cf2b\" class=\"graf graf--p graf-after--p\"><strong class=\"markup--strong markup--p-strong\">OBJECT DESTRUCTURING<\/strong><\/p>\n<figure id=\"2796\" class=\"graf graf--figure graf-after--p\">\n<div class=\"aspectRatioPlaceholder is-locked\">\n<div class=\"aspectRatioPlaceholder-fill\"><\/div>\n<div class=\"progressiveMedia js-progressiveMedia graf-image is-canvasLoaded is-imageLoaded\" data-image-id=\"1*FPuNAA4ZtrZHajrL_AGMSA.png\" data-width=\"443\" data-height=\"201\" data-scroll=\"native\"><canvas class=\"progressiveMedia-canvas js-progressiveMedia-canvas\" width=\"75\" height=\"32\"><\/canvas><img decoding=\"async\" class=\"progressiveMedia-image js-progressiveMedia-image\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*FPuNAA4ZtrZHajrL_AGMSA.png\" data-src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*FPuNAA4ZtrZHajrL_AGMSA.png\" \/><\/div>\n<\/div>\n<\/figure>\n<p id=\"4d8b\" class=\"graf graf--p graf-after--figure\">Here title,width,height is respectively assigned the values of options.title,options.width,options.height.<\/p>\n<figure id=\"1aef\" class=\"graf graf--figure graf-after--p\">\n<div class=\"aspectRatioPlaceholder is-locked\">\n<div class=\"aspectRatioPlaceholder-fill\"><\/div>\n<div class=\"progressiveMedia js-progressiveMedia graf-image is-canvasLoaded is-imageLoaded\" data-image-id=\"1*PVApORmfzv8ajFFt39RqlQ.png\" data-width=\"560\" data-height=\"285\" data-scroll=\"native\"><canvas class=\"progressiveMedia-canvas js-progressiveMedia-canvas\" width=\"75\" height=\"37\"><\/canvas><img decoding=\"async\" class=\"progressiveMedia-image js-progressiveMedia-image\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*PVApORmfzv8ajFFt39RqlQ.png\" data-src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*PVApORmfzv8ajFFt39RqlQ.png\" \/><\/div>\n<\/div>\n<\/figure>\n<p id=\"8ba7\" class=\"graf graf--p graf-after--figure\">Here options.width value is saved in variable w,options.height is saved in variable h. The colon shows \u201cwhat\u00a0: goes where\u201d. In the example above the property\u00a0<code class=\"markup--code markup--p-code\">width<\/code>\u00a0goes to\u00a0<code class=\"markup--code markup--p-code\">w<\/code>, property\u00a0<code class=\"markup--code markup--p-code\">height<\/code>\u00a0goes to\u00a0<code class=\"markup--code markup--p-code\">h<\/code>, and\u00a0<code class=\"markup--code markup--p-code\">title<\/code>\u00a0is assigned to the same name.<\/p>\n<figure id=\"32da\" class=\"graf graf--figure graf-after--p\">\n<div class=\"aspectRatioPlaceholder is-locked\">\n<div class=\"aspectRatioPlaceholder-fill\"><\/div>\n<div class=\"progressiveMedia js-progressiveMedia graf-image is-canvasLoaded is-imageLoaded\" data-image-id=\"1*DpscT9iKg2N2sf0Bg6C5Vw.png\" data-width=\"646\" data-height=\"163\" data-scroll=\"native\"><canvas class=\"progressiveMedia-canvas js-progressiveMedia-canvas\" width=\"75\" height=\"17\"><\/canvas><img decoding=\"async\" class=\"progressiveMedia-image js-progressiveMedia-image\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*DpscT9iKg2N2sf0Bg6C5Vw.png\" data-src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*DpscT9iKg2N2sf0Bg6C5Vw.png\" \/><\/div>\n<\/div>\n<\/figure>\n<p id=\"e60b\" class=\"graf graf--p graf-after--figure\">Here in the above example we have assigned default values.<\/p>\n<p id=\"0b68\" class=\"graf graf--p graf-after--p\"><strong class=\"markup--strong markup--p-strong\">NESTED DESTRUCTURING<\/strong><\/p>\n<figure id=\"68c1\" class=\"graf graf--figure graf-after--p\">\n<div class=\"aspectRatioPlaceholder is-locked\">\n<div class=\"aspectRatioPlaceholder-fill\"><\/div>\n<div class=\"progressiveMedia js-progressiveMedia graf-image is-canvasLoaded is-imageLoaded\" data-image-id=\"1*Kj4WjQQ1fHxJdWMsVBoCAQ.png\" data-width=\"751\" data-height=\"424\" data-action=\"zoom\" data-action-value=\"1*Kj4WjQQ1fHxJdWMsVBoCAQ.png\" data-scroll=\"native\"><canvas class=\"progressiveMedia-canvas js-progressiveMedia-canvas\" width=\"75\" height=\"40\"><\/canvas><img decoding=\"async\" class=\"progressiveMedia-image js-progressiveMedia-image\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*Kj4WjQQ1fHxJdWMsVBoCAQ.png\" data-src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*Kj4WjQQ1fHxJdWMsVBoCAQ.png\" \/><\/div>\n<\/div>\n<\/figure>\n<p id=\"7968\" class=\"graf graf--p graf-after--figure\">In the above example,The options object has size object inside it and items array.The extra variable is not destructured since in the left assignment it is not present.Also since the title is not present in the object it takes the default value.<\/p>\n<p id=\"4630\" class=\"graf graf--p graf-after--p\"><strong class=\"markup--strong markup--p-strong\">FUNCTION PARAMETERS AND DESTRUCTURING<\/strong><\/p>\n<figure id=\"76d2\" class=\"graf graf--figure graf-after--p\">\n<div class=\"aspectRatioPlaceholder is-locked\">\n<div class=\"aspectRatioPlaceholder-fill\"><\/div>\n<div class=\"progressiveMedia js-progressiveMedia graf-image is-canvasLoaded is-imageLoaded\" data-image-id=\"1*3VvKKeuqBSzjhIhTINnNuA.png\" data-width=\"693\" data-height=\"272\" data-scroll=\"native\"><canvas class=\"progressiveMedia-canvas js-progressiveMedia-canvas\" width=\"75\" height=\"27\"><\/canvas><img decoding=\"async\" class=\"progressiveMedia-image js-progressiveMedia-image\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*3VvKKeuqBSzjhIhTINnNuA.png\" data-src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*3VvKKeuqBSzjhIhTINnNuA.png\" \/><\/div>\n<\/div>\n<\/figure>\n<p id=\"3014\" class=\"graf graf--p graf-after--figure\">Here the parameters in curly braces {} are destructured with object options as shown in the last line.So title takes value from options.title and similarly width,height take default values and items array takes elements from options.items array.<\/p>\n<p id=\"8be1\" class=\"graf graf--p graf-after--p\">So what\u2019s the actual use of all this? Well when you are actually building a webapps, these concepts are detrimental for monitoring data present in arrays and objects, mutating them sometimes without having any change in the array and sometimes by some change in the original array.<\/p>\n<p id=\"c0a5\" class=\"graf graf--p graf-after--p\"><em class=\"markup--em markup--p-em\">Pheww,that was a lot to learn.I hope this was something interesting for you guys.Let\u2019s meet another time with some more interesting fundamentals!<\/em><\/p>\n<p id=\"0f69\" class=\"graf graf--p graf-after--p\">About me<\/p>\n<p id=\"33c8\" class=\"graf graf--p graf-after--p\"><em class=\"markup--em markup--p-em\">Hey I am Sneha,a foodie\u00a0,music-lover,future entrepreneur,gamer,a sophomore at Indian Institute of Information Technology, Allahabad (A Centre of Excellence in Information Technology established by Ministry of HRD, Govt. of India) and member of\u00a0<\/em><a class=\"markup--anchor markup--p-anchor\" href=\"https:\/\/www.facebook.com\/geekhaveniiita\/\" target=\"_blank\" rel=\"noopener nofollow\" data-href=\"https:\/\/www.facebook.com\/geekhaveniiita\/\"><em class=\"markup--em markup--p-em\">Geekhaven<\/em><\/a><em class=\"markup--em markup--p-em\">.<\/em><\/p>\n<p id=\"1a49\" class=\"graf graf--p graf-after--p\"><em class=\"markup--em markup--p-em\">I am a great fan of promoting women in tech and work with organizations like\u00a0<\/em><a class=\"markup--anchor markup--p-anchor\" href=\"https:\/\/www.facebook.com\/Girlscript\/\" target=\"_blank\" rel=\"noopener nofollow\" data-href=\"https:\/\/www.facebook.com\/Girlscript\/\"><em class=\"markup--em markup--p-em\">Girlscript<\/em><\/a><em class=\"markup--em markup--p-em\">,Djangogirls,Pyladies and\u00a0<\/em><a class=\"markup--anchor markup--p-anchor\" href=\"https:\/\/www.facebook.com\/kranti.india\/\" target=\"_blank\" rel=\"noopener nofollow\" data-href=\"https:\/\/www.facebook.com\/kranti.india\/\"><em class=\"markup--em markup--p-em\">Kranti<\/em><\/a><em class=\"markup--em markup--p-em\">.If you find this interesting feel free to ping me!<\/em><\/p>\n<p id=\"dc31\" class=\"graf graf--p graf-after--p graf--trailing\"><em class=\"markup--em markup--p-em\">If you guys liked the article,please show some \u2764.Stay tuned for more.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Javascript (JS) is a scripting languages, primarily used on the Web. It is used to enhance HTML pages and is [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":86,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[49,44,47,29],"tags":[],"class_list":["post-484","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-back-end","category-javascript","category-medium","category-programacion"],"_links":{"self":[{"href":"https:\/\/blog.hassler.ec\/wp\/wp-json\/wp\/v2\/posts\/484","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.hassler.ec\/wp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.hassler.ec\/wp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.hassler.ec\/wp\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.hassler.ec\/wp\/wp-json\/wp\/v2\/comments?post=484"}],"version-history":[{"count":2,"href":"https:\/\/blog.hassler.ec\/wp\/wp-json\/wp\/v2\/posts\/484\/revisions"}],"predecessor-version":[{"id":504,"href":"https:\/\/blog.hassler.ec\/wp\/wp-json\/wp\/v2\/posts\/484\/revisions\/504"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.hassler.ec\/wp\/wp-json\/wp\/v2\/media\/86"}],"wp:attachment":[{"href":"https:\/\/blog.hassler.ec\/wp\/wp-json\/wp\/v2\/media?parent=484"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.hassler.ec\/wp\/wp-json\/wp\/v2\/categories?post=484"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.hassler.ec\/wp\/wp-json\/wp\/v2\/tags?post=484"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}