まるでドッグ?イヤ`のごとく篁するフロントエンド_kに藤れていませんか娠哨札奪轡腑鵑任蓮BabelやPostCSSの秘の碧圭や聞い圭を盾hすることによって、肝弊旗の癖であるEcmaScript 6やCSS 3を枠函りし、Lく聞える室gを附につけます。送れの堀さに雌わされないようにしましょう。
Koji Ishimoto @IWATE HTML5 COMMUNITY #3 on October 14
https://www.facebook.com/events/674956182641567/
44. ブロックスコ`プ Let + Const
var x = 'var x';
var y = 'var y';
{
let x = 'let x';
const y = 'const x';
}
var x = 'var x';
var y = 'var y';
{
var _x = 'let x';
var _y = 'const x';
}
ES6
45. 哈方と處麻徨 Default + Rest + Spread
function add(x, y=2) {
return x + y;
}
add(3) == 5
function add(x) {
var y = arguments.length <= 1 || arguments[1] ===
undefined ? 2 : arguments[1];
return x + y;
}
ES6
オススメ
47. 哈方と處麻徨 Default + Rest + Spread
function multiple(x, y, z) {
return x * y * z;
}
multiple(...[1,2,3]) == 6
function multiple(x, y, z) {
return x * y * z;
}
multiple.apply(undefined, [1, 2, 3]) == 6;
ES6
オススメ
48. 蛍護旗秘 Destructuring Assignment
var [a, , b] = [1,2,3];
var {name: c, age: d} = {name: 't32k', age: 32};
var _ref = [1, 2, 3];
var a = _ref[0];
var b = _ref[2];
var _name$age = { name: 't32k', age: 32 };
var c = _name$age.name;
var d = _name$age.age;
ES6
49. テンプレ`ト Template Strings
var name = 't32k', age = 'today';
`Hello ${name}.
You are ${time} years old.`
var name = 't32k',
age = 'today';
"Hello " + name + ".n You are " + time + " years
old.";
ES6
オススメ
56. Map + Set + WeakMap + WeakSet
// Sets
var s = new Set();
s.add("hello").add("goodbye").add("hello");
s.size === 2;
s.has("hello") === true;
// Maps
var m = new Map();
m.set("hello", 42);
m.set(s, 34);
m.get(s) == 34;
// Weak Maps
var wm = new WeakMap();
wm.set(s, { extra: 42 });
wm.size === undefined
// Weak Sets
var ws = new WeakSet();
ws.add({ data: 42 });
勣: Poly?ll
ES6
57. モジュ`ル Modules
// lib/math.js
export function sum(x, y) {
return x + y;
}
export var pi = 3.14;
// app.js
import * as math from "lib/math";
alert(math.sum(math.pi, math.pi));
ES6
ES6
58. モジュ`ル Modules
// lib/math.js
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.sum = sum;
function _interopRequireWildcard(obj) { if (obj &&
obj.__esModule) { return obj; } else { var newObj = {}; if
(obj != null) { for (var key in obj) { if
(Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] =
obj[key]; } } newObj["default"] = obj; return newObj; } }
// app.js
var _libMath = require("lib/math");
var math = _interopRequireWildcard(_libMath);
function sum(x, y) {
return x + y;
}
var pi = 3.14;exports.pi = pi;
alert(math.sum(math.pi, math.pi));
92. hwb()
body {
color: hwb(90, 0%, 0%, 0.5);
}
/* Q瘁のCSS */
body {
color: rgba(128, 255, 0, 0.5);
}
ED
Spec:
Plugin:
CSS Color Module Level 4 - HWB Colors: hwb() function
postcss/postcss-color-hwb
93. gray()
body {
color: gray(255, 50%);
}
/* Q瘁のCSS */
body {
color: rgba(255, 255, 255, 0.5);
}
ED
Spec:
Plugin:
CSS Color Module Level 4 - The gray() functional notation
postcss/postcss-color-gray
94. #rrggbbaa
body {
background: #99DD99CC
}
/* Q瘁のCSS */
body {
background: rgba(153, 221, 153, 0.8)
}
ED
Spec:
Plugin:
CSS Color Module Level 4 - The RGB hexadecimal notations
postcss/postcss-color-hex-alpha
95. rebeccapurple
body {
background: rebeccapurple
}
/* Q瘁のCSS */
body {
background: rgb(102, 51, 153)
}
ED
Why this plugin?
If you did some CSS, I'm sure you know who Eric Meyer is, & what he did for this language.
In memory of Eric Meyer¨s daughter, W3C added new color rebeccapurple to CSS 4 Color
Module.
Spec:
Plugin:
CSS Color Module Level 4 - Named Colors
postcss/postcss-color-rebeccapurple