Posts

Destructuring Assignment in ES6- Arrays

Destructuring assignment is a cool feature that came along with ES6. Destructuring is a JavaScript expression that makes it possible to unpack values from arrays, or properties from objects, into distinct variables. That is, we can extract data from arrays and objects and assign them to variables. Why is this necessary? Imagine if we want extract a data from an array. Previously, how will this be done? var introduction = ["Hello", "I" , "am", "Sarah"]; var greeting = introduction[0];// here we r assigning greeting key to above value var name = introduction[3]; console.log(greeting);//"Hello" // outputing console.log(name);//"Sarah" We can see that when we want to extract data from an array , we had to do the same thing over and over again. ES6 destucturing assignment makes it easier to extract this data. How is this so? This article discusses destructuring assignment of arrays. My next article...

rest operator

Image
// Without rest parameter function fun(a, b){ return a + b; } console.log(fun(1, 2)); // 3  takes only 1st 2 parameters for sum of a + b console.log(fun(1, 2, 3, 4, 5)); // 3 // es6 rest parameter  function fun( ... input ){  let sum = 0;  for(let i of input){  sum+= i ;  }  return sum;  }  console.log(fun(1,2)); //3  console.log(fun(1,2,3)); //6  console.log(fun(1,2,3,4,5)); //15  

spread operator

Image

javascript notes

Image
Javascript [.js] Introduction: HTML’s first version, designed by Tim Berners-Lee from 1989 to 1991, was fairly static in nature.  Except for link jumps with the a element, web pages simply displayed content, and the content was fixed.  In 1995, the dominant browser manufacturer was Netscape, and one of its employees, Brendan Eich, thought that it would be useful to add dynamic functionality to web pages.  So he designed the JavaScript programming language, which adds dynamic functionality to web pages when used in conjunction with HTML.  For example, JavaScript provides the ability to update a web page’s content when an event occurs, such as when a user clicks a button.  It also provides the ability to retrieve a user’s input and process that input. Javascript is scripting or interpreted language .i.e the code executes line by line when the browser load the javascript into the memory.  Why JavaScript: JavaScript adds beha...