Javascript ES6 — Primitive types vs Objects # 12

There is something you should know before the spread operators lesson, I’m talking here about javascript data types, and this is a requirement before moving into the next lesson of this series of ES6 videos, this not a complete lesson about data types, I’ll explain the difference between two main categories of data types.

Read More

Javascript ES6 — Array.some() and Array.every() # 11

You’ve here a couple of numbers,

const numbers = [4, 6, 3, 8];

and you want just a quick answer of Yes or No following a specific condition, as an example you want to check if any number of this array is odd, or if any number from this list is less than 10, so the some method is built for that, it checks if any element in an array following an ascending order, from index 0 to index 3, is passing a specific test, if any of the tests pass it’ll return true, otherwise if all the elements don’t pass the test, it’ll return false.

Read More

Javascript ES6 — Array.from() and Array.of() # 10

In general, and if you’ve an array colors, you can access to each color respectively using a for of loop

const colors = ["red", "green", "blue"];

for (let color of colors) {
  console.log(color);
}

This colors is considered as an iterable object, and because I want to confuse little bit, so if you don’t already know, an array is an object.

Read More

Javascript ES6 — Array.find() and Array.findIndex() # 9

We’ve here a list of users, so we’ve got an array, and at each index, we’ve got a specific object user that has an id, fullName, email and gender, our goal is, to find a user that matches a specific criteria, as an example we want to search for a user that has a fullName of Rex Michael.

Read More

Javascript ES6 — The for loop # 8

In general, if you’ve got a list, and you want to get each element from this list, or in other words if you want to iterate over elements of an array you use the old style for loop.

Read More

Javascript ES6 — Destructuring Functions # 7

So far you learn how to destructure arrays and objects, so if you don’t already follow the previous courses, I suggest taking a look to them before jumping into destructuring functions.

Destructure a returned object

Okay let’s now go for some real examples, We start with a function that returns an object, for that you create a getStudentInfo function, that has no argument, we’ll use the es6 arrow function syntax, add the fat arrow, this function will return an object, so open the parenthesis, and add the brackets, and add the properties name, and age.

const getStudentInfo = () => ({
 name: "John Doe",
 age: 22,
});

Read More

Javascript ES6 — Destructuring Arrays # 6

As we already learn, that destructuring assignment is the way of unpacking values from object and arrays into specific variables, in other words, destructuring implies breaking complex structure into simpler parts. let’s now go for some examples of destructuring arrays, and let’s go for a new studentInfo array, that has as a value the student id, student, name, and a city.

const studentInfo = [8643, "Maria Carter", "Washington"];

Read More

Javascript ES6 — Destructuring Objects # 5

Destructuring assignment is a special syntax that allows unpacking arrays or objects into a bunch of variables. Destructuring an Object In general, if you want to get the value of the name and the color properties from the car object, you have to create two variables, name that has a value of car.name.
Read More

Javascript ES6 — Template Literals # 4

To create a string in javascript you’ve two choices, single quote or double
quotes, in case of a raw text you can create your string with no problem.

const message = "Hello";

Once you want to add a variable into this string, you’ve to use the plus sign to
do the concatenation, let’s create a variable name, and concatenate its value to
the message variable.

Read More

Javascript ES6 — Arrow Functions # 3

Arrow functions is a new way of writing functions using a simpler syntax, and the version of javascript that supports arrow functions is es6, or ECMAScript 6, in general, many modern browsers supporting the use of arrow functions, however, if you’re in a situation of cross-browser validation, when you’ve to support old javascript versions like es5, in this case you can transpile your code to an older version.

Okay, let’s move to our subject, sometimes arrow functions can also be called fat arrow functions, because of the used fat arrow symbols, and let’s just list some of the pros of this new syntax.

Read More