Created
August 31, 2011 14:02
-
-
Save pocotan001/1183608 to your computer and use it in GitHub Desktop.
Utilities
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* getElementById wrapper. | |
* @param {String} 要素の一意のIDを表す文字列 | |
* @returns {Element} 一致する要素 | |
*/ | |
function $(id){ | |
return $[id] || ($[id] = document.getElementById(id)); | |
} | |
/** | |
* オブジェクトを拡張 | |
* @param {Object} 拡張されるオブジェクト | |
* @param {Object} 拡張元のオブジェクト1 | |
* @param {Object} [objectN] 拡張元のオブジェクトN | |
* @returns {Object} 拡張されたオブジェクト | |
*/ | |
function extend(/*target, object1, [objectN]*/){ | |
var target = arguments[0] || {}; | |
for(var i = 1, n = arguments.length; i < n; i++){ | |
for(var prop in arguments[i]){ | |
target[prop] = arguments[i][prop]; | |
} | |
} | |
return target; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment