热点
模块化思维实战:后端站长从0到1构建高效网站,reasoning_content:我们要求以后端站长的口吻,写一个与“技术、科技”相关,关于[从0到1:运用模块化思维与实战技巧,轻松构建高效网站]的标题需要简短精炼,30字以内直接输出标题,不要加说明nn可以考虑:后端站长视角,强调模块化思维和实战技巧,从0到1构建高效网站可能的从0到1:后端站长教你模块化构建高效网站 但字数可能超?数一下:从0到1:后端站长教你模块化构建高效网站 —— 共18个字符(包括标点)?汉字每个算一个字,冒号、空格?严格来说:从0到1:后端站长教你模块化构建高效网站 共16个字(从0到1:后端站长教你模块化构建高效网站,数一下:从0到1:(3个汉字+1个冒号?不,是从0到1是4个字符,但通常算4个?我们按汉字+符号更好的:去掉一些词nn模块化思维实战:后端站长从0到1建高效站 数一下:模块化思维实战:后端站长从0到1建高效站 —— 共18个?模块化思维实战(6字)冒号(1)后端站长(4)从0到1(4)建高效站(4)总19?有点多nn更简洁:模块化构建高效网站:后端站长的从0到1 共14个字?模块化构建高效网站:后端站长的从0到1 —— 13个汉字+1冒号+1数字?其实从0到1是4个字符可以nn或者:后端站长:模块化思维从0到1打造高效网站 共16字?后端站长:模块化思维从0到1打造高效网站 —— 数:后(1)端(2)站(3)长(4):(5)模(6)块(7)化(8)思(9)维(10)从(11)0(12)到(13)1(14)打(15)造(16)高(17)效(18)网(19)站(20) —— 20字,超了nn要控制在30字以内,所以20字以内都行但最好更精炼nn考虑直接用原话中的从0到1和模块化思维、实战技巧、高效网站但题目要求以后端站长口吻,所以可以加上后端站长nn思路:从0到1:后端站长的模块化实战,高效网站轻松建 数一下:从0到1:后端站长的模块化实战,高效网站轻松建 —— 从0到1(4)冒号(1)后端站长(4)的(1)模块化实战(5)逗号(1)高效网站(4)轻松建(3)总共4+1+4+1+5+1+4+3=23字可以nn更简洁:模块化思维实战:后端站长从0到1建高效站 前面数过19字nn或者:后端站长带你从0到1模块化构建高效网站 15字nn注意:要求与技术、科技相关,但标题本身已经涉及nn我会选择:后端站长:模块化思维从0到1轻松构建高效网站 数:后(1)端(2)站(3)长(4):(5)模(6)块(7)化(8)思(9)维(10)从(11)0(12)到(13)1(14)轻(15)松(16)构(17)建(18)高(19)效(20)网(21)站(22) —— 22字可以nn另一个:从0到1:后端站长模块化实战构建高效网站 22字左右nn为了更口语化:从0到1轻松建站:后端站长教你模块化实战 15字?从0到1轻松建站:后端站长教你模块化实战 —— 共18字?nn我最后决定用:从0到1:模块化+实战,后端站长教你轻松建高效站 数:从0到1:模块化+实战,后端站长教你轻松建高效站 —— 共?从(1)0(2)到(3)1(4):(5)模(6)块(7)化(8)+(9)实(10)战(11),(12)后(13)端(14)站(15)长(16)教(17)你(18)轻(19)松(20)建(21)高(22)效(23)站(24) —— 24字略长去掉教你变成从0到1:模块化+实战,后端站长轻松建高效站 22字nn或者直接:模块化思维实战:后端站长从0到1构建高效网站 18字?数一下:模(1)块(2)化(3)思(4)维(5)实(6)战(7):(8)后(9)端(10)站(11)长(12)从(13)0(14)到(15)1(16)构(17)建(18)高(19)效(20)网(21)站(22) —— 22字还是22nn我认为22字完全在30字以内可以输出这个nn注意:不要加任何说明直接输出标题
15 9 月 2026, 周二

jQuery1.8.2源码解析之jQuery.Callbacks,已经在代码中添加了详细的注释,有需要的朋友看下边的代码就可以了。这样在使用时就方便了许多。

代码:

Copy to ClipboardLiehuo.Net Codes引用的内容:[www.veryhuo.com]
// String to Object options format cache
// 是对option的一个缓存,避免每次都要createOptions
// 每一个option类似这样
// {
// memory : true
// ,once : true
// ,…
// }
var optionsCache = {};

// Convert String-formatted options into Object-formatted ones and store in cache
function createOptions( options ) {
var object = optionsCache[ options ] = {};
jQuery.each( options.split( core_rspace ), function( _, flag ) {
object[ flag ] = true;
});
return object;
}

/*
* Create a callback list using the following parameters:
*
* options: an optional list of space-separated options that will change how
* the callback list behaves or a more traditional option object
*
* By default a callback list will act like an event callback list and can be
* "fired" multiple times.
*
* Possible options:
*
* once: will ensure the callback list can only be fired once (like a Deferred)
*
* memory: will keep track of previous values and will call any callback added
* after the list has been fired right away with the latest "memorized"
* values (like a Deferred)
*
* unique: will ensure a callback can only be added once (no duplicate in the list)
*
* stopOnFalse: interrupt callings when a callback returns false
*
*/
jQuery.Callbacks = function( options ) {

// Convert options from String-formatted to Object-formatted if needed
// (we check in cache first)
// options也可以是一个对象
options = typeof options === "string" ?
( optionsCache[ options ] || createOptions( options ) ) :
jQuery.extend( {}, options );

var // Last fire value (for non-forgettable lists)
memory,
// Flag to know if list was already fired
fired,
// Flag to know if list is currently firing
firing,
// First callback to fire (used internally by add and fireWith)
firingStart,
// End of the loop when firing
firingLength,
// Index of currently firing callback (modified by remove if needed)
firingIndex,
// Actual callback list
list = [],
// Stack of fire calls for repeatable lists
// 只有在没有设置了once时,stack才存在
// stack用来存储参数信息(此时函数列表已经处于firing状态,必须将其他地方调用fire时的参数存储,之后再至此执行fire
stack = !options.once && [],
// Fire callbacks
fire = function( data ) {
// 如果设置memory,那么每一次fire的数据将会被保存在memory中,作为下次调用add时参数
memory = options.memory && data;
fired = true;
firingIndex = firingStart || 0;
// 重置fireStarting为0,因为add操作(memory)可能改变它
firingStart = 0;
firingLength = list.length;
firing = true;
for ( ; list && firingIndex < firingLength; firingIndex++ ) {
// 如果设置了stopOnFalse参数,那么当函数列表中有某个函数返回false时,停止后面函数的执行,并且取消memory(如果设置了)
if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) {
memory = false; // To prevent further calls using add
break;
}
}
firing = false;
if ( list ) {
// 如果stack存在,那么将之前存储的第一个参数取出,继续fire,直到stack为空
if ( stack ) {
if ( stack.length ) {
fire( stack.shift() );
}
// 如果stack不存在(即设置了once)
// 那么如果设置了memory,那么将之前函数列表清空,也就是说memory还在,add操作可以处罚函数立即执行
} else if ( memory ) {
list = [];
} else {
self.disable();
}
}
},
// Actual Callbacks object
// 实际返回的Callbacks对象
self = {
// Add a callback or a collection of callbacks to the list
// 添加函数或者函数集(数组或者伪数组)到函数列表中去
add: function() {
if ( list ) {
// First, we save the current length
var start = list.length;
(function add( args ) {
jQuery.each( args, function( _, arg ) {
var type = jQuery.type( arg );
// 如果arg是函数
// 如果设置unique,则在list中查找是否函数已存在,若存在忽略掉,否则push进list
// 如果没有设置unique,则直接push进list
if ( type === "function" && ( !options.unique || !self.has( arg ) ) ) {
list.push( arg );

// 如果arg是数组或者伪数组,则递推push进list
} else if ( arg && arg.length && type !== "string" ) {
// Inspect recursively
// 递归(成员为函数集)
add( arg );
}
});
})( arguments );
// Do we need to add the callbacks to the
// current firing batch?
// 在添加函数(集)时

// 如果函数列表正在依次执行回调函数(即firing状态),在某一个callback中执行add(fn)操作
// 那么立即修改fireLength以便fire时函数列表能够执行到刚添加的函数(集)
if ( firing ) {
firingLength = list.length;
// With memory, if we’re not firing then
// we should call right away
// 如果不是firing状态,并且设置了memory(肯定是在fired状态时才会执行这一步,因为memory是在fire一次后才会被负值)
// 此时memory已经是上次fire是传递的参数,那么将会直接执行刚添加的函数集,而无需fire
} else if ( memory ) {
firingStart = start;
fire( memory );
}
}
return this;
},
// Remove a callback from the list
// 从函数列表中删除函数(集)
remove: function() {
if ( list ) {
jQuery.each( arguments, function( _, arg ) {
var index;
// while循环的意义在于借助于强大的jQuery.inArray删除函数列表中相同的函数引用(没有设置unique的情况)
// jQuery.inArray将每次返回查找到的元素的index作为自己的第三个参数继续进行查找,直到函数列表的尽头
// splice删除数组元素,修改数组的结构
while( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
list.splice( index, 1 );
// Handle firing indexes
// 在函数列表处于firing状态时,最主要的就是维护firingLength和firgingIndex这两个值
// 保证fire时函数列表中的函数能够被正确执行(fire中的for循环需要这两个值)
if ( firing ) {
if ( index <= firingLength ) {
firingLength–;
}
if ( index <= firingIndex ) {
firingIndex–;
}
}
}
});
}
return this;
},
// Control if a given callback is in the list
// 判断函数列表只能够是否包含给定的fn
has: function( fn ) {
return jQuery.inArray( fn, list ) > -1;
},
// Remove all callbacks from the list
// 清空函数列表
empty: function() {
list = [];
return this;
},
// Have the list do nothing anymore
// 使函数列表作废(不能再做任何事情)
disable: function() {
list = stack = memory = undefined;
return this;
},
// Is it disabled?
// 判断是否函数列表是否disabled
disabled: function() {
return !list;
},
// Lock the list in its current state
lock: function() {
stack = undefined;
if ( !memory ) {
self.disable();
}
return this;
},
// Is it locked?
locked: function() {
return !stack;
},
// Call all callbacks with the given context and arguments
// 和fire相似,不相同的是fireWith可以给定上下文参数
// fire中就是调用fireWith中的context就是this(函数列表对象self)
fireWith: function( context, args ) {
args = args || [];
args = [ context, args.slice ? args.slice() : args ];
// 首先至少fire一次
// 如果执行过一次了(fired),那么若stack存在(即没有设置once),将上下文环境和参数存储,否则什么都不做
if ( list && ( !fired || stack ) ) {
if ( firing ) {
stack.push( args );
} else {
fire( args );
}
}
return this;
},
// Call all the callbacks with the given arguments
// 依次执行函数列表中的函数
fire: function() {
self.fireWith( this, arguments );
return this;
},
// To know if the callbacks have already been called at least once
// 判断是否函数列表fire过(哪怕只有一次)
fired: function() {
return !!fired;
}
};

return self;
};

dawei

【声明】:北京站长网内容转载自互联网,其相关言论仅代表作者个人观点绝非权威,不代表本站立场。如您发现内容存在版权问题,请提交相关链接至邮箱:bqsm@foxmail.com,我们将及时予以处理。

您错过了

模块化思维实战:后端站长从0到1构建高效网站,reasoning_content:我们要求以后端站长的口吻,写一个与“技术、科技”相关,关于[从0到1:运用模块化思维与实战技巧,轻松构建高效网站]的标题需要简短精炼,30字以内直接输出标题,不要加说明nn可以考虑:后端站长视角,强调模块化思维和实战技巧,从0到1构建高效网站可能的从0到1:后端站长教你模块化构建高效网站 但字数可能超?数一下:从0到1:后端站长教你模块化构建高效网站 —— 共18个字符(包括标点)?汉字每个算一个字,冒号、空格?严格来说:从0到1:后端站长教你模块化构建高效网站 共16个字(从0到1:后端站长教你模块化构建高效网站,数一下:从0到1:(3个汉字+1个冒号?不,是从0到1是4个字符,但通常算4个?我们按汉字+符号更好的:去掉一些词nn模块化思维实战:后端站长从0到1建高效站 数一下:模块化思维实战:后端站长从0到1建高效站 —— 共18个?模块化思维实战(6字)冒号(1)后端站长(4)从0到1(4)建高效站(4)总19?有点多nn更简洁:模块化构建高效网站:后端站长的从0到1 共14个字?模块化构建高效网站:后端站长的从0到1 —— 13个汉字+1冒号+1数字?其实从0到1是4个字符可以nn或者:后端站长:模块化思维从0到1打造高效网站 共16字?后端站长:模块化思维从0到1打造高效网站 —— 数:后(1)端(2)站(3)长(4):(5)模(6)块(7)化(8)思(9)维(10)从(11)0(12)到(13)1(14)打(15)造(16)高(17)效(18)网(19)站(20) —— 20字,超了nn要控制在30字以内,所以20字以内都行但最好更精炼nn考虑直接用原话中的从0到1和模块化思维、实战技巧、高效网站但题目要求以后端站长口吻,所以可以加上后端站长nn思路:从0到1:后端站长的模块化实战,高效网站轻松建 数一下:从0到1:后端站长的模块化实战,高效网站轻松建 —— 从0到1(4)冒号(1)后端站长(4)的(1)模块化实战(5)逗号(1)高效网站(4)轻松建(3)总共4+1+4+1+5+1+4+3=23字可以nn更简洁:模块化思维实战:后端站长从0到1建高效站 前面数过19字nn或者:后端站长带你从0到1模块化构建高效网站 15字nn注意:要求与技术、科技相关,但标题本身已经涉及nn我会选择:后端站长:模块化思维从0到1轻松构建高效网站 数:后(1)端(2)站(3)长(4):(5)模(6)块(7)化(8)思(9)维(10)从(11)0(12)到(13)1(14)轻(15)松(16)构(17)建(18)高(19)效(20)网(21)站(22) —— 22字可以nn另一个:从0到1:后端站长模块化实战构建高效网站 22字左右nn为了更口语化:从0到1轻松建站:后端站长教你模块化实战 15字?从0到1轻松建站:后端站长教你模块化实战 —— 共18字?nn我最后决定用:从0到1:模块化+实战,后端站长教你轻松建高效站 数:从0到1:模块化+实战,后端站长教你轻松建高效站 —— 共?从(1)0(2)到(3)1(4):(5)模(6)块(7)化(8)+(9)实(10)战(11),(12)后(13)端(14)站(15)长(16)教(17)你(18)轻(19)松(20)建(21)高(22)效(23)站(24) —— 24字略长去掉教你变成从0到1:模块化+实战,后端站长轻松建高效站 22字nn或者直接:模块化思维实战:后端站长从0到1构建高效网站 18字?数一下:模(1)块(2)化(3)思(4)维(5)实(6)战(7):(8)后(9)端(10)站(11)长(12)从(13)0(14)到(15)1(16)构(17)建(18)高(19)效(20)网(21)站(22) —— 22字还是22nn我认为22字完全在30字以内可以输出这个nn注意:不要加任何说明直接输出标题