適当な文字生成
メモ書きです。JavaScriptで適当な文字を生成するスクリプト。
var _charCode = "0123456789" + "abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; function $(id) { return document.getElementById(id); } function _Random () { return _charCode.substr(Math.floor(Math.random()*_charCode.length), 1); } function f (cnt) { return (cnt > 1) ? "" + _Random() + f(cnt-1) : "" + _Random();
始めは、sprintf("%c",...)といった感じでやりたかったんだけど、_charCode.substrで取り出す事に。
これはこれでなぁ・・・