Toby Rogers

Toby Rogers

1605749811

JavaScript Spread Operator (ES6 Tutorial)

Learn JavaScript Spread Operator (ES6 Tutorial)

Using the spread operator in JavaScript (ES6) can be helpful in our daily programming lives,
so in this video, we are going to talk about the JavaScript Spread Operator, what it does, how to use it with some examples including arrays, objects, and functions.

Sections:

  • (0:00) - Intro
  • (0:29) - The Spread Syntax
  • (01:16) - Merging Arrays with Concat & Spread
  • (02:25) - String Example with Split Method & Spread
  • (02:54) - Passing as an argument to Math Function
  • (04:18) - Merging Objects with Spread Operator
  • (04:52) - Outro

#javascript #es6 #programming #developer #web-development

What is GEEK

Buddha Community

JavaScript Spread Operator (ES6 Tutorial)

Santosh J

1622036598

JavaScript compound assignment operators

JavaScript is unarguablly one of the most common things you’ll learn when you start programming for the web. Here’s a small post on JavaScript compound assignment operators and how we use them.

The compound assignment operators consist of a binary operator and the simple assignment operator.

The binary operators, work with two operands. For example a+b where + is the operator and the a, b are operands. Simple assignment operator is used to assign values to a variable(s).

It’s quite common to modify values stored in variables. To make this process a little quicker, we use compound assignment operators.

They are:

  • +=
  • -+
  • *=
  • /=

You can also check my video tutorial compound assignment operators.

Let’s consider an example. Suppose price = 5 and we want to add ten more to it.

var price = 5;
price = price + 10;

We added ten to price. Look at the repetitive price variable. We could easily use a compound += to reduce this. We do this instead.

price += 5;

Awesome. Isn’t it? What’s the value of price now? Practice and comment below. If you don’t know how to practice check these lessons.

Lets bring down the price by 5 again and display it.
We use console.log command to display what is stored in the variable. It is very help for debugging.
Debugging let’s you find errors or bugs in your code. More on this later.

price -= 5;
console.log(price);

Lets multiply price and show it.

price *=5;
console.log(price);

and finally we will divide it.

price /=5;
console.log(price);

If you have any doubts, comment below.

#javascript #javascript compound assignment operators #javascript binary operators #javascript simple assignment operator #doers javascript

Eldora  Bradtke

Eldora Bradtke

1594059180

Rest Parameter and Spread Operator

The Rest Parameter

A Rest Parameter is used as the last argument of a function declaration. It is enabling the user to specify any number of parameters.

function sumUp(...nums) {
	  return nums.reduce((acc, cur) => acc = Number(acc + cur), 0);
	}

	console.log(sumUp(1, 2, 3));
	// -> 6

A function can also have common parameters as long as the Rest Parameter is the last one.

	function myHero(name, level, ...abilities) {
	  return `My hero ${name} on level ${level} has the following abilities: ${abilities.join(", ") || 'none'}.`;
	}

	console.log(myHero('Arthas', 55, 'Attack', 'Blizzard'));
	// -> My hero Arthas on level 55 has the following abilities: Attack,Blizzard.

	console.log(myHero('Thrall', 1));
	// -> My hero Thrall on level 1 has the following abilities: none.

Rest Parameter vs. Arguments

Arguments is an Array-like Object; we cannot directly apply Array-functions to it. We have to make use of the Spread Operator to unfold the Arguments Object in an Array first. For instance: In the last example, we could apply the join method directly to our abilities parameter.

function sumUp() {
	  return [...arguments].reduce((acc, cur) => acc = Number(acc + cur), 0);
	}

	console.log(sumUp(1, 2, 3));
	// -> 6

#spread-operator #es6 #rest-parameter #learn-javascript #javascript-basics #javascript

Tanya  Shields

Tanya Shields

1593530460

JavaScript: Spread Operator and Rest Parameter (ES6)

The spread operator and rest parameter are two other powerful features introduced in ECMAScript 2015 and they allow us to write more concise and flexible code like most of the other ES6 features do. The several different ways you can use spread and rest syntax will be covered in this article.


Spread Operator

The spread operator allows us to expand the collected elements of an iterable data type like strings, arrays, or objects into individual elements in places. It helps to create a list of elements from a list by spreading out the values of an iterable where zero or more arguments (function calls) or elements (array literals) or key-value pairs (object literals) are expected.

1. In Function Calls:

The spread operator can be used to take elements of an array and pass them as a list of arguments into a function. Let’s take a look at how it works:

The elements of an array are passed to a function as arguments

The function printColors takes in three parameters and we want to pass three arguments stored in colors array. When we call the function, the spread operator unpacks the passed array of arguments, ‘red’‘blue’, and ‘yellow’.

#es6 #javascript #rest-parameter #programming #spread-operator

Terry  Tremblay

Terry Tremblay

1602147513

Now Learn JavaScript Programming Language With Microsoft

icrosoft has released a new series of video tutorials on YouTube for novice programmers to get a hands-on renowned programming language — JavaScript.

This isn’t the first attempt by Microsoft to come up with video tutorials by beginner programmers. The company also has a series of YouTube tutorials on Python for beginners.

For JavaScript, Microsoft has launched a series of 51 videos as ‘Beginner’s Series to JavaScript,’ for young programmers, developers and coders who are interested in building browser applications using JavaScript. These video tutorials will also help programmers and coders to use relevant software development kits (SDKs) and JavaScript frameworks, such as Google’s Angular.


“Learning a new framework or development environment is made even more difficult when you don’t know the programming language,” stated on the Microsoft Developer channel on YouTube. “Fortunately, we’re here to help! We’ve created this series of videos to focus on the core concepts of JavaScript.”

It further stated — while the tutorials don’t cover every aspect of JavaScript, it indeed will help in building a foundation from which one can continue to grow. By the end of this series, Microsoft claims that the novice programmers will be able to work through tutorials, quick starts, books, and other resources, continuing to grow on their own.


#news #javascript #javascript tutorial #javascript tutorials #microsoft tutorials on javascript

wp codevo

wp codevo

1608042336

JavaScript Shopping Cart - Javascript Project for Beginners

https://youtu.be/5B5Hn9VvrVs

#shopping cart javascript #hopping cart with javascript #javascript shopping cart tutorial for beginners #javascript cart project #javascript tutorial #shopping cart