vinissh

Ecma2019-Atualizações

Dec 27th, 2019
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. * String.trimStart();
  3. * String.trimEnd();
  4. */
  5.  
  6. let olaMundo = "    Olá Mundo   ";
  7. let olaStart = olaMundo.trimStart();
  8. let olaEnd = olaMundo.trimEnd();
  9.  
  10.  
  11. /*
  12. * Parametro no catch opcional;
  13. */
  14.  
  15. try {
  16.     throw "erro";
  17. } catch {
  18.     console.error("Ocorreu um erro");
  19. }
  20.  
  21.  
  22. /*
  23. * Array.flat()
  24. * Array.flatMap()
  25. */
  26.  
  27. let cadeirasPorSemestre = [
  28.     ["Cálculo 1", ["Programação", "Estrutura de Dados"], ["Projeto 1", "Normas Academicas"], "Banco de Dados"],
  29.     ["Redes", ["Programação Web", "Compiladores", ["Projeto 2", "Produção de Texto"]], "Micro controladores"]
  30. ];
  31.  
  32. cadeiras = cadeirasPorSemestre.flat();
  33. cadeiras = cadeirasPorSemestre.flat(2);
  34. cadeiras = cadeirasPorSemestre.flat(Infinity);
  35.  
  36. //Obs.: FlatMap faz apenas um nivel = flat(1)
  37. notasFlat = [7.8, 6.2, 8.0, 6.4].flatMap(nota => [nota, Math.round(nota)]);
  38.  
  39.  
  40. /*
  41. * Object.fromEntries()
  42. */
  43.  
  44. let vetAlunos= [
  45.     ["maria", 17],
  46.     ["carlos", 21],
  47.     ["pedro", 21],
  48.     ["tatiana", 16],
  49. ];
  50.  
  51. let objAlunos= Object.fromEntries(vetAlunos);
  52.  
  53.  
  54. /*
  55. * function.toString()
  56. */
  57.  
  58. function mensagem() {
  59.     const name = 'MundoJS';
  60.     console.log(`Bem-vindo ao ${name}`);
  61. }
  62.  
  63. mensagem.toString();
  64.  
  65. /*
  66. * Symbol.description
  67. */
  68.  
  69. const laranja = Symbol('Uma Laranja');
  70. console.log(laranja.description);
  71.  
  72.  
  73. /*
  74. * Array.sort()
  75. */
  76.  
  77. const alunos = [
  78.     { nome: "Alan", nota: 9 },
  79.     { nome: "Bruna", nota: 8 },
  80.     { nome: "Carlos", nota: 10 },
  81.     { nome: "Cristina", nota: 10 },
  82.     { nome: "Diego", nota: 7 },
  83.     { nome: "Eliana", nota: 8 },
  84.     { nome: "Fabio", nota: 9 },
  85. ]
  86.  
  87. alunos.sort((a, b) => a.nota - b.nota);
  88.  
  89. /*
  90. * Well Formed Json
  91. * Subsume JSON
  92. */
  93.  
  94. // Agora
  95. JSON.stringify('\uD800');
  96. // Antes: '"�"'
  97. // Agora: '"\\ud800"'
  98.  
  99. // Uma string contendo o separador de linha
  100. const LineSeparator = eval('"\u2028"');;
  101. // ES2018: SyntaxError
  102. // ES2019: no exception
  103.  
  104. // Uma string contendo o separador de paragrafo
  105. const ParagraphSeparator = eval('"\u2029"');
  106. // ES2018: SyntaxError
  107. // ES2019: no exception
Advertisement
Add Comment
Please, Sign In to add comment