#content

言語仕様

ES2015(ES6)

言語仕様

let再代入可能
const再代入不可能
const [a, b, c, d] = ['a', 2, {c: '300'}, '四'];一度に変数宣言と代入
console.log(`わたしは${a}`);文字列展開
export HOGE = 'HOGE'importすれば別ファイルから利用できる。

オブジェクト展開

const arg =

アロー関数

const fn = (a, b) => a + b;
const oneArgs = a => a * 2;
const noArgs =()=> console.log('Hello, world!');  // 引数なしの書き方は()のみ
const fn = (a, b) => {
  return a + b;
};
const fn = funciont(a, b) { return a + b; }
function Add(a,b) { return a + b; }

スプレッド演算子

const array = [1, 10, 3];
console.log(...array);
const func2 = (...r) => console.log(...r);

呼び出しに変数名を指定させる

const full = ({first,last}) =>  { return first + last; };
full({ first:'苗字',last:'名前'});

React

Redux

参考サイト

Chromeでデバッグ

https://app.codegrid.net/entry/breakpoint-1

クラスの定義

// この一文でprototypeプロパティが使えるようになる
function Foo() {};
// ここで定義を代入。
Foo.prototype = {
    init:function() { alert('A');},
    test:function() { alert('B');}
};
// newして使う必要があるのか・・・
var foo = new Foo();
foo.init();
function Foo() {};
Foo.prototype = {
    init:function() { alert('A');},
    test:function() { alert('B');}
};
Foo.A = function()
{
    alert('A is static');
}
Foo.B = function()
{
    alert('B is static');
}
// newして使う必要があるのか・・・
var foo = new Foo();
foo.init();
// prototypeをはさまないとそのまま実行可能!
Foo.A();
Foo.B();

便利なライブラリ

Prototype.js

一昔前の主流

JQuery

2009年現在はこちらのほうがよろしいらしい。

http://www.slideshare.net/hayatomizuno/jquery-7665168

プラグインの作り方

http://web-terminal.blogspot.jp/2012/11/jquery4.html

onLoadで動かす。

$(function () { alert('test'); });

タイマーを仕込む

setInterval(function(){ alert('test'); },10000);

指定の要素の数をカウントする。

if ($('#探したい場所のID .その配下のクラス').length > 0) { alert('test'); }

関数が定義されているかをチェックする

alert(typeof($.cookies.set));

定義されていればobjectとでる。

Jqueryのセレクタ

$('li')
$('li.hoge')
$('li#hoge')
$('DIV#contents LI')
$('DIV#contents > LI')
$('#first, #third")
$("a[href]").each(function(){
}
$("DIV#hoge a[href]").each(function(){
}
$("input[type='checkbox']").removeAttr( 'checked' );
$("input[type='checkbox']").attr( 'checked', 'checked' );

属性セレクタ

$("[href]")
$("[href='hoge']")
$("[href^='hoge']")
$("[href$='hoge']")

フォームの操作

変更関連(フォーカスON,OFF,変更)

$("input").("focus",function(){});
$("input").("blur",function(){});
$("input").("change",function(){});

フォーム用のセレクター

input[type='text']
input[type='password']
input[type='radio']
input[type='checkbox']
input[type='submit']
input[type='image']

セレクトされたもの、チェックされたもの

:selected
:checked

Joose

その他

Rhino

JavaでかかれたJavaScript実装。J2SE6.0から標準添付


トップ   編集 凍結 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2022-10-14 (金) 13:16:53