print 'Hello YKazu'

('Python', 'Javascript')

Javascript

aタグからサブミット

<a href="javascript:void(0)" onclick="document.forms[0].submit(); return false;">Login</a>

コンストラクタのプロパティ

// コンストラクタ var Car = function(id){ this.id = id; this.type = "truck"; } console.log(Car.id); // undefined console.log(Car.type); // undefined Car.id = 3; Car.type = 'sedan'; console.log(Car.id); // 3 console.log(Car.type); // sedan …

Validator

正規表現でチェックする var Validator = function(){}; Validator.prototype.isNumber = function(param) { return /[0-9]+/.test(param); }; var validator = new Validator(); var i = 85; if (validator.isNumber(i)) { console.log("number"); } else {…

display属性の確認

display属性はjQueryで簡単に確認出来る <h1 class="h1">Yoshida</h1> <img src="yoshida.png" alt="yoshida" class="img"> console.log($('.h1').css('display')); // block console.log($('.img').css('display')); // inline

クロージャ

counter = function() { var i=1; return { count: function() { return i; }, up: function() { i = i + 1; }, init: function() { i = 1; } }; }; // 実行コンテキストcounter()の終了 // 同時にクロージャの生成 closure = counter(); // コンテキストの…

日付処理

Moment.js | Home MySQLのDatetime型(2016-06-04 03:30:15)に整形したり、便利そう。

デフォルト引数

function fn(arg) { arg = typeof arg === 'undefined' ? 0 : arg; return ++arg; } console.log(fn()); //=> 1 console.log(fn(0)); //=> 1 console.log(fn(1)); //=> 2