https://flic.kr/p/m9738v
Learn JS in Kanazawa
kakenai.js ver.1.0
https://flic.kr/p/npvsQJ
@pocotan001
Hayato Mizuno
https://frontendweekly.tokyo/
http://blocsapp.com/
http://electron.atom.io/
http://electron.atom.io/
https://flic.kr/p/9gpNkP
https://flic.kr/p/dSuxV1
Choose JS Tools Today
EditorConfig
http://editorconfig.org/
root = true
!
[*]
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
!
[*.md]
trim_trailing_whitespace = false
.editorconfig
黒い画面
command -options arguments
sh
command -options arguments
!
coffee -wc a.coffee
sh
command -options arguments
!
coffee -wc a.coffee
# coffee -w -c a.coffee
# coffee --watch --compile a.coffee
sh
パッケージ
マネージャー
&
npm i -g xxx
# npm install —-global xxx
https://goo.gl/2Uq21X
その他
56%
grunt

4%
pm2

4%
gulp

7%
bower
11%
grunt-cli
18%
~/…lib # npm root -g
node_modules
coffee-script
npm i -g coffee-script
coffee …
sh
your-project
node_modules
coffee-script
npm i coffee-script
coffee …
# command not found: coffee
sh
your-project
node_modules
coffee-script
npm i -D coffee-script
sh
—save-dev
package.json
{
…
"dependencies": { … },
"devDependencies": {
"coffee-script": "^1.9.2"
}
}
package.json
your-project
node_modules
coffee-script
npm i -S jquery
sh
—save
package.json
jquery
{
…
"dependencies": {
"jquery": "^2.1.4"
},
"devDependencies": {
"coffee-script": "^1.9.2"
}
}
package.json
https://plugins.jquery.com/
https://plugins.jquery.com/
We recommend moving to npm,
using "jquery-plugin" as the
keyword in your package.json.
http://blog.npmjs.org/post/101775448305/npm-and-front-end-packaging
https://speakerdeck.com/watilde/npm-update-g-npm
モジュールローダー
http://browserify.org/
var $ = require('jquery');
!
console.log($.fn.jquery); // 2.1.4
a.js
npm i -g browserify
browserify a.js -o bundle.js
# your-project/bundle.js
sh
Browserify WebPack
https://gist.github.com/substack/68f8d502be42d5cd4942
タスクランナー
npm i -g grunt-cli
npm i –D grunt grunt-contrib-coffee
grunt build
sh
npm i -g gulp
npm i –D gulp gulp-coffee
gulp build
module.exports = function(grunt) {
grunt.initConfig({
coffee: {
compile: {
files: {
'./a.js': './a.coffee'
}
}
}
});
!
grunt.loadNpmTasks('grunt-contrib-coffee');
grunt.registerTask('build', ['coffee']);
};
Gruntfile.js
var gulp = require('gulp');
var coffee = require('gulp-coffee');
!
gulp.task('coffee', function() {
return gulp.src(['./a.coffee'])
.pipe(coffee())
.pipe(gulp.dest('./'));
});
!
gulp.task('build', ['coffee']);
Gulpfile.js
gulp.src(['./a.coffee'])
.pipe(coffee())
.pipe(uglify())
.pipe(rename('a.min.js'))
.pipe(gulp.dest('./'));
Gulpfile.js
https://github.com/greypants/gulp-starter
{
…
"scripts": {
"build": "coffee -c a.coffee"
}
}
package.json
sh
npm i -D coffee-script
npm run build
http://blog.keithcirkel.co.uk/how-to-use-npm-as-a-build-tool/
altJS,
トランスパイラ
http://coffeescript.org/
greeting = -> "Hello"
alert greeting()
!
// var greeting;
//
// greeting = function() {
// return "Hello";
// };
//
// alert(greeting());
a.coffee
https://babeljs.io/
let greeting = () => 'Hello';
alert( greeting() );
!
// 'use strict';
//
// var greeting = function greeting() {
// return 'Hello';
// };
//
// alert(greeting());
a.js
http://browserify.org/
var $ = require('jquery');
!
console.log($.fn.jquery); // 2.1.4
a.js
import $ from 'jquery';
!
console.log($.fn.jquery); // 2.1.4
a.js
npm i browserify babelify
browserify a.js -t babelify -o bundle.js
sh
http://codemix.com/blog/why-babel-matters
http://havelog.ayumusato.com/develop/javascript/e665-ts_jsx_flux.html
Lint
http://eslint.org/
.eslintrc
{
"parser": "babel-eslint",
"rules": {
"quotes": [1, "single"],
"no-var": 2,
...
},
"env": {
"browser": true,
...
}
}
https://github.com/airbnb/javascript/tree/master/packages/eslint-config-airbnb
https://github.com/feross/eslint-config-standard
npm -D eslint eslint-config-airbnb
sh
.eslintrc
{
"extends": "airbnb"
...
}
http://jscs.info/
https://github.com/jscs-dev/node-jscs/tree/master/presets
https://medium.com/dev-channel/auto-formatting-javascript-code-style-fe0f98a923b8
ユニットテスト
console.assert(1 + 1 == 2);
test.js
console.assert(
1 + 1 == 2,
'1 + 1 は 2 であること'
);
test.js
console.assert(
1 + 1 == 3,
'1 + 1 は 2 であること'
);
!
Assertion failed: 1 + 1 は 2 であること
test.js
http://mochajs.org/
describe('足し算のテスト', function() {
!
it('1 + 1 は 2 であること', function() {
console.assert(1 + 1 == 2);
})
!
});
test.js
mocha test.js
sh
足し算のテスト
✓ 1 + 1 は 2 であること
!
1 passing
mocha test.js
sh
足し算のテスト
1) 1 + 1 は 2 であること
!
0 passing
1 failing
https://nodejs.org/api/assert.html
var assert = require('assert');
!
describe('足し算のテスト', function() {
!
it('1 + 1 は 2 であること', function() {
assert.equal(1 + 1, 2);
})
!
});
test.js
assert.equal();
assert.notEqual();
!
assert.deepEqual();
assert.notDeepEqual();
!
assert.throws();
…
mocha test.js // console.assert
sh
…
AssertionError: false == true
+ expected - actual
!
-false
+true
mocha test.js // node.js assert
sh
…
AssertionError: 2 == 3
+ expected - actual
!
-2
+3
mocha test.js // power-assert
sh
…
# test.js:6
!
assert(1 + 1 === 3)
| |
2 false
!
[number] 3
=> 3
[number] 1 + 1
=> 2
https://github.com/power-assert-js
http://dev.classmethod.jp/testing/10_errors_about_unit_testing/
MVなんたら
http://www.slideshare.net/ginpei_jp/js-modelview
https://goo.gl/2J3ZCr
https://facebook.github.io/flux/docs/overview.html
Flux?
https://medium.com/@milankinen/good-bye-flux-welcome-bacon-rx-23c71abfb1a7
コンポーネント
- Custom Elements

- HTML Imports

- Template

- Shadow DOM
http://webcomponents.org/
http://webcomponents.org/articles/interview-with-joshua-peek/
https://customelements.io/
https://www.polymer-project.org/1.0/
https://facebook.github.io/react/
- Just the UI

- Virtual DOM

- Data Flow
https://facebook.github.io/react/
var Button = React.createClass({
render: function() {
return (
<button type={this.props.type}>
{this.props.children}
</button>
);
}
});
!
React.render(
<Button type="submit">Hello</Button>,
document.getElementById('example')
);
a.jsx
setState()
setState()
再描画
再描画
http://blog.500tech.com/is-reactjs-fast/
…
The most dangerous thought you can have as a creative person is to
think you know what you re doing. Learn tools, and use tools, but
don t accept tools. Always distrust them; always be alert for
alternative ways of thinking.
“想像的であり続けるために避けなければならないことは、
自分がやっていることを知っていると思い込むことです。
ツールを学び、ツールを使いこなす。しかし、ツールの全
てを受け入れてはなりません。
どんな時でも別の視点で考えるようにするべきです。
- Victor, Bret. “The Future of Programming.”
http://quote.enja.io/post/the-most-dangerous-thought-you-can-have.../
https://flic.kr/p/m9738v
QUESTION?

"今" 使えるJavaScriptのトレンド