阅读Crockfords JavaScript样式的元素我注意到他更喜欢定义这样的变量:
var first='foo', second='bar', third='...';
Run Code Online (Sandbox Code Playgroud)
如果该方法有任何好处,那么:
var first='foo';
var second='bar';
var third='...';
Run Code Online (Sandbox Code Playgroud)
显然,后者需要更多的打字,但除了美学外,我想知道是否通过定义前一种风格获得了性能优势.
我有一组如下设置的路线:
routes: {
'!/home': 'home',
'!/home/:page': 'home'
}
Run Code Online (Sandbox Code Playgroud)
我想知道的是,我如何配置路由,以便如果用户请求未知页面,我可以轻松地重定向到静态404.html页面?
阅读在标题为"Faces of " 的部分中编写一致的惯用JavaScript的原则,this
它表明this
JavaScript 中的别名"非常容易出错".
我个人尝试尽可能使用_.bind()
(或类似的东西),但有人知道为什么混叠this
是如此容易出错?
我用以下方法创建一个动态变量(PHP用语中的"变量变量"):
foo: "test1"
set to-word (rejoin [foo "_result_data"]) array 5
Run Code Online (Sandbox Code Playgroud)
但是,如何动态获取名为"test1_result_data"的结果变量的值?我尝试了以下方法:
probe to-word (rejoin [foo "_result_data"])
Run Code Online (Sandbox Code Playgroud)
但它只返回"test1_result_data".
如果我记得的话,Zend引擎的原始设计之一是,它可能相对容易嵌入其他人可能希望创建的语言.基本上,没有所有PHP模块的PHP语法.这仍然是这样吗?
我有一个PHP数组,我正在解析以获取电子邮件地址.有时我会想要评论一个条目,所以我可以使用不同的值进行测试.
这是一个数组的例子:
array('system.email' => array(
'to' => array(
'contactus' => 'contactus@example.com',
'newregistration' => 'newreg@example.com',
'requestaccess' => 'requestaccess@example.com',
// 'workflow' => 'workflow@example.com'
'workflow' => 'test_workflow@example.com'
)
));
Run Code Online (Sandbox Code Playgroud)
这是我的PARSE规则:
parse read %config.php [
thru "'system.email'" [
thru "'to'" [thru "'workflow'" [thru "'" copy recipient-email to "'^/"]]
] to end
]
Run Code Online (Sandbox Code Playgroud)
当我运行它时,值为recipient-email
"workflow@example.com".如何编写我的规则,使其忽略以//
?开头的行?
我一直在玩jQuery的Events方法,我使用以下代码构建了一个简单的事件总线:
$(window).on('test:event', function (event, data) {
console.log('Saw a test event: event=%o, data=%o', event, data);
});
$(window).trigger('test:event', {test_data: 'foo'});
Run Code Online (Sandbox Code Playgroud)
我的问题是,使用"窗口"管理事件有什么问题吗?
我正在执行一些代码,然后在1秒到1分钟之间等待.我目前正在使用,random 0:01:00 /seed
但我真正需要的是能够设置一个地板,使其在30秒到1分钟之间等待.
我想出了如何检查OR案例,preg_match( "/(word1|word2|word3)/i", $string );
.我无法弄清楚如何匹配AND案例.我想检查字符串是否包含所有术语(不区分大小写).
php ×3
rebol ×3
javascript ×2
backbone.js ×1
jquery ×1
performance ×1
preg-match ×1
rebol3 ×1
regex ×1