es6.js 884 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. 'use strict';
  2. // ArrowFunctionExpression
  3. ["Model", "View", "Controller"].forEach(name => console.log(name));
  4. // ClassBody, ClassDeclaration, MethodDefinition
  5. class Socket {
  6. constructor(port) {
  7. // ...
  8. }
  9. open() {
  10. // ...
  11. }
  12. close() {
  13. // ...
  14. }
  15. }
  16. // ClassExpression
  17. var WebSocket = class extends Socket {
  18. // ...
  19. };
  20. // ExportBatchSpecifier, ExportDeclaration
  21. export * from 'lib/network';
  22. // ExportSpecifier
  23. export {Socket};
  24. // ImportDeclaration, ImportSpecifier
  25. import {Packet} from 'lib/data';
  26. // ModuleDeclaration
  27. module util from 'lib/util';
  28. // SpreadElement
  29. function logItems(...items) {
  30. items.forEach(function(item) {
  31. console.log(item);
  32. });
  33. }
  34. logItems(...['hello', 'world!']);
  35. // TaggedTemplateExpression
  36. console.log`hello world!`;
  37. // TemplateElement, TemplateLiteral
  38. var piMessage = `pi equals ${Math.PI}`;