ES6 Questions.

Which functions and shorthand of ES6 are currently being utilized by the MV Engine? It seems like some things work and some don't.


This is a topic for people to post what they have tested and what currently works.
That's actually a good question... I ended up using some Array or String (can't recall which) functions that were apparently ES6, and they worked as expected. Later I found out they were ES6 functions and redid them, just in case. Specifically, I used .includes.


Array.includes


String.includes


The MV developers may have included the provided polyfill somewhere in the MV code - I have not searched it all that extensively. If so, I imagine it would be somewhere in rpg_core in JsExtensions.
Just tested another ES6 shorthand in MV, and it works. (Using Template Literals) 
var name = 'mike';                      //single quotes here still to declare a string.
$gameMessage.add(`My name is ${name}.`);         //it just looks cleaner.


This is using back ticks (`) instead of single quotes (') i know they look the same but the back tick is the ~ key.


Instead of writing:


var name = 'mike';


$gameMessage.add('My name is' + name + '.');    //messy.
 
I actually created a list of what works concerning ES6, there are some more features, but these are some.


@Driftwood Gaming


In terms of short hands:

  • Object shorthands
  • Template literals



Here are the object short hands


var name = "Ryan";
var age = 34;

var person = {
name,
age,
sayName() {
console.log(`Hello my name is ${name}`);
}




If you have a variable with a specific name, you can just pass the variable into the object to use as a key.


You also can declare functions within an object like sayName above.

Original thread: https://forums.rpgmakerweb.com/threads/es6-questions.67963/