Skip to main content

Posts

Showing posts from September, 2017

Javascript

Question : example of Map Reduce Answer : (() => { let aNumberArray = [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 ] ; let sum = aNumberArray. map (data => data * 2 ) . reduce ((ongoing , data) => ongoing + data) ; console . log (sum) ; })() Question : What is IIFE? Answer  : Immediately Invoked function expression e.g. (function(){}()). usually pronounces as " effy ". Question : Why the script tag should be added at the bottom or before the end of the body tag? Answer  : It helps the html page to render quickly without even downloading the script which may be getting downloaded from the slow CDN. there are other alternative like async and defer as well, which are supported primarily on new browsers.     <script src="bower_components/angular/angular.min.js" defer></script>     <script src="bower_components/jquery/dist/jquery.min.js" defer></script>     <script src="bower_components/boo