.DS_Store
# Learn ES6 (ECMAScript 2015)
![](https://d2eip9sf3oo6c2.cloudfront.net/series/square_covers/000/000/049/full/EGH_LearnES6_Final.png?1496436434)
This course takes a look at some of the new features that JavaScript has available with ES6 (ECMAScript 2015). It is a "montage" from several instructors.
Each lesson's code is in its corresponding lesson folder. Plunks are drawn from the lesson's branch.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Plunker</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>
//Maps and WeakMaps with ES6
var myMap = new Map();
//API
/*
set()
get()
size
clear()
has()
*/
var myObj = {};
var myFunc = function(){};
myMap.set(myObj, 'bar');
myMap.set(myFunc, 'world');
myMap.set('string', 2);
console.log('get on myMap = ' + myMap.get(myObj)) || displayInPreview('get on myMap = ' + myMap.get(myObj));
//myMap.clear();
console.log('has on non-existing key = ' + myMap.has('qwerty')) || displayInPreview('has on non-existing key = ' + myMap.has('qwerty'));
//Iterators
//keys()
//entries()
//values
for(var [key, value] of myMap.entries()){
console.log(key + ' = ' + value) || displayInPreview(key + ' = ' + value);
}
//WeakMap Restrictions
/*
Because no references to keys are stored we do not have access to methods that require the ability to iterate the map such as:
keys()
values()
entries()
AND
clear()
*/
var myWeakMap = new WeakMap();
var myObj2 = {};
var myFunc2 = function(){};
myMap.set(myObj2, 'bar');
myMap.set(myFunc2, 'world');
console.log(myMap.get(myObj)) || displayInPreview(myMap.get(myObj));
// display in plunker preview
function displayInPreview(string) {
var newDiv = document.createElement("div");
var newContent = document.createTextNode(string);
newDiv.appendChild(newContent);
document.body.appendChild(newDiv)
}