好奇如果选择其中一种方法比另一种方法有任何好处.这是一个例子.
'one two'.split(' ').map(string => doSomething(string));
Run Code Online (Sandbox Code Playgroud)
VS
['one', 'two'].map(string => doSomething(string));
Run Code Online (Sandbox Code Playgroud)
我已经在一些流行的前端库中看到了第一种方法,但是第二种方法在快速阅读代码时对我更有意义.这只是一种风格选择吗?或者是否有某种模糊的好处来分割一个间隔开的字符串而不仅仅是通过数组映射?
有人可以解释一下这个附加物中的附加物
JS
var app = angular.module('plunker', []);
app.controller('MainCtrl', function($scope, $interval) {
$scope.name = 'World';
var plop = $interval(function(){}, 1000);
$scope.test = function(){
console.log("test");
}
})
Run Code Online (Sandbox Code Playgroud)
HTML
<body ng-controller="MainCtrl">
<p ng-class="test()">Hello {{name}}!</p>
</body>
Run Code Online (Sandbox Code Playgroud)
如果你打开控制台,你可以看到"test"正在重复输出,但它不在$ interval函数中!
所以我只是将我的twitter机器人推送到Heroku,并设置在半小时内使用Heroku调度程序插件每小时运行一次.但是,无论出于何种原因,它每10分钟运行一次.这是调度程序的错误吗?以下是调度程序成功运行时的日志摘录,然后十分钟后再次尝试运行它:
2013-01-30T19:30:20+00:00 heroku[scheduler.4875]: Starting process with command `python ff7ebooks.py`
2013-01-30T19:30:21+00:00 heroku[scheduler.4875]: State changed from starting to up
2013-01-30T19:30:24+00:00 heroku[scheduler.4875]: Process exited with status 0
2013-01-30T19:30:24+00:00 heroku[scheduler.4875]: State changed from up to complete
2013-01-30T19:34:34+00:00 heroku[web.1]: State changed from crashed to starting
2013-01-30T19:34:42+00:00 heroku[web.1]: Starting process with command `python ff7ebooks.py`
2013-01-30T19:34:44+00:00 heroku[web.1]: Process exited with status 0
2013-01-30T19:34:44+00:00 heroku[web.1]: State changed from starting to crashed
Run Code Online (Sandbox Code Playgroud)
我可以提供任何人需要的任何信息来帮助我诊断这个问题.[web.1]日志消息每隔几分钟重复一次.我不想向我的粉丝发送垃圾邮件.