jQueryやPrototypeなどの一般的なJavaScriptライブラリで(シングル)ドル記号の使用を理解します。私はまた、PHP(変数変数)の二重ドル記号の意義を理解しています。ディーンエドワーズは有名なダブルドル記号を使用していますaddEvent() JavaScript機能。ここでは、二重ドル記号の使用を含む除き、次のとおりです。JavaScriptダブルドル記号
function addEvent(element, type, handler) {
// assign each event handler a unique ID
if (!handler.$$guid) handler.$$guid = addEvent.guid++;
// create a hash table of event types for the element
if (!element.events) element.events = {};
// create a hash table of event handlers for each element/event pair
var handlers = element.events[type];
if (!handlers) {
handlers = element.events[type] = {};
// store the existing event handler (if there is one)
if (element["on" + type]) {
handlers[0] = element["on" + type];
}
}
// store the event handler in the hash table
handlers[handler.$$guid] = handler;
// assign a global event handler to do all the work
element["on" + type] = handleEvent;
};
// a counter used to create unique IDs
addEvent.guid = 1;
私が何を読んでから、その基準が主な原因に今日無視されているが、ドル記号は正式に、コード生成ツールのJavaScriptで意義を持っています前述のJavaScriptライブラリでドル記号が広く使用されています。
誰もJavaScriptのダブルドル記号のこの使用法についてどんな光を当てることができますか?
ありがとうございました!
'addEvent'はIEでふるいのように漏れ出すように私には思えます。 – kangax