DEV Community

Cover image for JavaScript - Recent Parts
Abdur Rehman Khalid
Abdur Rehman Khalid

Posted on

1

JavaScript - Recent Parts

I am writing this post in order to highlight some of the recent parts of the modern JavaScript that have solved many problems of JavaScript that many JavaScript developers were waiting for.
So without any further chitchat let's get straight into the topic.

Template Strings

Template Strings have made it very easy to embedded variables into the Strings and also working with Strings have become easy as well.
In the following example we can easily use variables into the Strings.
Template Strings Example

Destructuring

One of my favourite feature of modern JavaScript. This feature allows the developer focused on what instead of how.
Destructuring allows to extract that data that is required to complete or do any specific work.
This feature of JavaScript requires another separate article because there are several types of Destructuring such as Array Destructuring and Object Destructuring.
Let's try to understand Object Destructuring by the means of the following example.
Destruct Example
Now What we are doing here is that getusers() will be returning the array os JSON objects that contains the information regarding the users, but we do not to have to completed response and we want only specific things to work with for example the First Name, Last Name and Profession. so by the Object Destructuring we can only receive array of objects having only these properties.

Array.flat()

The Array.flat() method on arrays allow to convert any Dimensional Array into one less dimensional array by default and if to a specific given value as well..
For example we have a 2D Array the Array.flat() will convert that 2D Array into 1D Array and so on.
So Let's have a look at the example of flat() function in action.
Flat Example
There are some other new methods related to Arrays as well such as find(), findIndex(), includes() as well. These methods are also very useful in order to do some common work related to Arrays as well.

Iterators and Generators

The JavaScript has provided us a way to consume the data inside a Data-source one by one until we have not reached to the end of that Data-Source.
Let's get on the example to understand this concept better and have a look at the Iterator and how we can work with it as well.
Iterator Example

So these were the some of the most simple and mine favourite JavaScript features that came out recently.

Sentry blog image

How to reduce TTFB

In the past few years in the web dev world, we’ve seen a significant push towards rendering our websites on the server. Doing so is better for SEO and performs better on low-powered devices, but one thing we had to sacrifice is TTFB.

In this article, we’ll see how we can identify what makes our TTFB high so we can fix it.

Read more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs