DEV Community

Mago Acadêmico
Mago Acadêmico

Posted on

3 3

ES6? ECMAScript? Entenda o que isso tem a ver com o Javascript

ES6 se refere a 6ª versão do ECMAScript.
ECMAScript é uma especificação de uma linguagem de script e o Javascript é a implementação dessa especificação.

O ECMAScript existe pois cada browser, seja chrome, firefox ou qualquer outro, possui diferentes implementações para que você possa rodar seu código Javascript, mas todos devem seguir a mesma especificação.

Imagina se para cada browser tivesse uma especificação diferente? Seria uma loucura

Algumas features novas no ES6

// Declaração de variáveis com let e const
let varLet = 123;
const varConst = 456;

// Arrow function
const arrowFunction = () => {};

// Classes
class Classes {}

// Template string
const templateStr = `${varLet} ${varConst}`;

// Promises
const delay = (duration = 0) =>
  new Promise((resolve, reject) => {
    setTimeout(resolve, duration);
  });

await delay(1000)

// E muito mais ...
Enter fullscreen mode Exit fullscreen mode

ES7

// Array includes
[1, 2, 3].includes(1) // => true
[1, 2, 3].includes(9) // => false
// Operador de exponenciação
10 ** 3 // => 10 * 10 * 10 = 1000
Enter fullscreen mode Exit fullscreen mode

ES8

// Async function
const asyncFunc = async () => {
    await delay();
}

// Object.entries e Object.values
const obj = { siga: 'agora', like: true }
Object.entries(obj) 
// => [['siga', 'agora'], ['like', true]]
Object.values(obj)
// => ['agora', 'true']

// E muito mais ...
Enter fullscreen mode Exit fullscreen mode

E existem varias outras versões como ES9, ES10, etc.

Se você quer ver todas as versões e entender mais sobre:

SurveyJS custom survey software

JavaScript UI Libraries for Surveys and Forms

SurveyJS lets you build a JSON-based form management system that integrates with any backend, giving you full control over your data and no user limits. Includes support for custom question types, skip logic, integrated CCS editor, PDF export, real-time analytics & more.

Learn more

Top comments (0)

nextjs tutorial video

Youtube Tutorial Series

So you built a Next.js app, but you need a clear view of the entire operation flow to be able to identify performance bottlenecks before you launch. But how do you get started? Get the essentials on tracing for Next.js from @nikolovlazar in this video series 👀

Watch the Youtube series

AWS GenAI LIVE!

GenAI LIVE! is a dynamic live-streamed show exploring how AWS and our partners are helping organizations unlock real value with generative AI.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️