function sum(a) {
var currentSum = a;
function f(b) {
currentSum += b;
return f;
}
f.toString = function() {
return currentSum;
};
return f;
}
alert( sum(1)(2) ); // 3
alert( sum(5)(-1)(2) ); // 6
alert( sum(6)(-1)(-2)(-3) ); // 0
alert( sum(0)(1)(2)(3)(4)(5) ); // 15
angular.module('applicaton', [])
.factory('fooBar', function() {
function Service() {
var param = null;
this.setParam = function(param) {
param = param;
};
this.getParam = function() {
return param;
};
}
return function() {
return new Service();
}
})
.directive('sample', function() {
return {
restrict: 'AE',
scope: false,
controller: function(fooBar) {
var service = fooBar();
service.setParam('test');
}
};
});
if (navigator.userAgent.indexOf("u3 kernel") !== -1) {
// UC Browser
}
"some random string".split(/[\s\-]/).slice(0, 2); // ["some", "random"]
"some-random string".split(/[\s\-]/).slice(0, 2); // ["some", "random"]
"some random-string".split(/[\s\-]/).slice(0, 2); // ["some", "random"]
"some-random-string".split(/[\s\-]/).slice(0, 2); // ["some", "random"]