diff --git a/resources/public/synonym.html b/resources/public/synonym.html index 6a3214e..21d40f0 100644 --- a/resources/public/synonym.html +++ b/resources/public/synonym.html @@ -59,13 +59,21 @@
// No native implementation+
// No native implementation pre-ES6.
+ // In ES6, all public members must be
+ // explicitly exported. Also, the file is
+ // the library - there is no namespaces.
+ export function foo () {
+ ...
+ }
(ns my.library)+
;; ClojureScript has support for +;; libraries, and they are in namespaces. +(ns my.library)
// No native implementation+
// No native implementation pre-ES6. +// In ES6, there is the following syntax: +import other, * as namespace from "other-library.js";
-// No native implementation, must pull
-// aparts objects and arrays manually
+// No native implementation pre-ES6, must
+// pull aparts objects and arrays manually
var o = {first: "Bob",
middle: "J",
@@ -183,7 +203,18 @@ Destructuring bind
var red = color[0];
var green = color[1];
var alpha = color[3];
-...
+...
+
+// In ES6:
+var o = {first: "Bob",
+ middle: "J",
+ last: "Smith"};
+
+var {first, middle, last} = o;
+
+var color = [255, 255, 100, 0.5];
+var [red, green, , alpha] = color;
+
var a = [...]; -foo(a.slice(0)); +foo(a.slice()); // if foo might mutate a, must clone, // however this is only a shallow copy @@ -641,7 +678,9 @@+// equality test for all types +// https://npm.im/deep-equal is +// frequently used for this.Equality
// == tests identity // must implement your own deep -// equality test for all types
-// No native implementation. Manipulate arguments
+// No native implementation pre-ES6. Manipulate arguments
// object explicitly. Performance implications.
function foo() {
var args = arguments;
...
}
-
+
+// In ES6, this is the syntax:
+function foo(...args) {
+ ...
+}
-// JavaScript does not have uniform iteration +// JavaScript pre-ES6 does not have uniform iteration // over native types. var colors = ['red', 'orange', 'green']; @@ -986,7 +1034,19 @@+ +// In ES6, there is the following syntax +// for iterables only (arrays, etc.): +let colors = ['red', 'orange', 'green'] + +for (let color of colors) { + console.log(color); +} + +for (let key of Object.keys(data)) { + console.log('key', key); + console.log('value', data[key]); +}Uniform Iteration For All Types
console.log('key', key); console.log('value', data[key]); } -