What is the difference between the binding methods of these two custom events? Which is better?

  node.js, question

The first way is to store custom events directly in __onfireEvents

var __onfireEvents = {};
 
 function _bind(eventName, callback, is_one, context) {
 if (typeof eventName !  == string_str || typeof callback !  == function_str) {
 Throw new Error('args:' plus string_str plus',' plus function_str plus');
 bracket
 if (!  hasOwnKey(__onfireEvents, eventName)) {
 __onfireEvents[eventName] = {};
 bracket
 __onfireEvents[eventName][ plus _ _ cnt] = [callback, is _ one, context];
 
 return [eventName, __cnt];
 bracket
 
 function on(eventName, callback, context) {
 return _bind(eventName, callback, 0, context);
 bracket

The second way is to store custom events, but the difference is that they are bound to elements. Is it necessary? Is there any advantage here?

$customSubMap = {};
 subscribeEvent = function ( $collection, event_name, fn ) {
 $collection.on( event_name, fn );
 
 
 if ( !  $customSubMap[ event_name ] ) {
 $customSubMap[ event_name ] = $collection;
 bracket
 else {
 $customSubMap[ event_name ]
 = $customSubMap[ event_name ].add( $collection );
 bracket
 };

Binding to an element seems to use jquery’s event binding. See if your custom event is used on dom elements. If it is only the first type of module-to-module transfer, if it is a dom event, it must be placed on the element, which is convenient to trigger.