DEV Community

Erasmus Kotoka
Erasmus Kotoka

Posted on

Introduction to ES6+ Features: Template Literals, Spread Operator, and Destructuring

  1. Template Literals

Use backticks (`) to easily insert variables into strings with ${}.


const name = "John";

const message = `Hello, ${name}!`;

Enter fullscreen mode Exit fullscreen mode
  1. Spread Operator ...

Spread array or object elements into another array/object or function.


const numbers = [1, 2, 3];

const moreNumbers = [...numbers, 4, 5]; // [1, 2, 3, 4, 5]

Enter fullscreen mode Exit fullscreen mode
  1. Destructuring

Quickly extract values from arrays or objects.


const person = { name: "Alice", age: 25 };

const { name, age } = person;

Enter fullscreen mode Exit fullscreen mode

KEEPCoding

WIthKOToka

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay