मैं jQuery और प्रोटोटाइप जैसे लोकप्रिय जावास्क्रिप्ट पुस्तकालयों में (एकल) डॉलर के संकेत के उपयोग को समझता हूं। मैं PHP (परिवर्तनीय चर) में डबल डॉलर के संकेत के महत्व को भी समझता हूं। डीन एडवर्ड्स अपने प्रसिद्ध addEvent() जावास्क्रिप्ट फ़ंक्शन में डबल डॉलर के चिह्न का उपयोग करता है। ,जावास्क्रिप्ट डबल डॉलर साइन
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;
मैं क्या पढ़ा है से, डॉलर चिह्न केवल आधिकारिक तौर पर कोड पीढ़ी उपकरणों के लिए जावास्क्रिप्ट में महत्व है, हालांकि यह है कि मानक काफी हद तक वजह से आज नजरअंदाज कर दिया है: यहाँ डबल डॉलर चिह्न के उपयोग से युक्त छोड़कर एक है डॉलर उपर्युक्त जावास्क्रिप्ट पुस्तकालयों में व्यापक उपयोग का संकेत देता है।
क्या कोई जावास्क्रिप्ट में दोहरे डॉलर के हस्ताक्षर के इस उपयोग पर कोई प्रकाश डाल सकता है?
बहुत बहुत धन्यवाद!
यह है कि इस 'addEvent' IE में एक छलनी की तरह रिसाव हो जाएगा मुझे लगता है। – kangax