ECMAScript 6
ECMAScript 6
var name;
*global
let name
*used for local scope vars. Index in a loop or joining string together.
const name
*not reassignable
`${}`
*Template string. It pre-formats partially any string in console, alert, doc.write, etc… Vars inside it stay in
${var}
new Map();
*to create a map object. It’s a key-value object type. Keys can be functions, arrays, etc. any primitive.
person.get(“name”)
Person.has(“key”)
Person.keys() ou .values();
*returns all the keys ou values. And we can iterate through each key or value
Person.forEach(function(person){
Console.log(person)
})
[“sth”],
]);
ou
numSet.add(“john”);
numSet.add(“paul”);
numSet.has(“john”)
numSet.size
console.log(x)}
let person = {
console.log(person.name());
() => {}
Let personsName = name => console.log(name)//’cuz we’ve only 1 parameter and code line
personsName(“Dário”);
let [first, , , last] = [“Javascript”, “Java”, “Ruby”, “Python”]; // last gets python
*for distructuring assignment. First gets javascript and last gets java, etc…
function* myFunc(i){
yield i;
yield i + 5;}
console.log(gen.next());//runs yield i + 5
*for generators function
class person{
this.name = name;
this.age = age;
this.profession = profession};
console.log(alfred);
*to declare a class. With one constructor function name, which serves to create and initialize class objs
this.school = school;
this.grade = grade;
}}
console.log(louis);
this.school = school;
this.grade = grade;
getName(){return this.name;}
setName(name){this.name = name}
*to set the getters and setters of the class. Are just simple methods
ou
if (finishedWork){
resolved();
}else {reject()}
});
*to declare promises. If a var is true do sth. And then do something. Used to retrieve the datas from
servers
*to fetch data from server, simpler than Promise. Json() converts the response data into json.