function count() {
var i = 0;
return function _next_() {
return i++;
};
}
function fibonacci(x) {
var result = 0;
// do staff begin
if (x === 0 || x === 1) {
result = 1;
}
for (let a = 1, b = 1, i = 2; i <= x; i++) {
result = a + b;
a = b;
b = result;
}
// do staff end
return result;
}
function factorial(x) {
var result = 0;
// do staff begin
result = 1;
for (let i = 1; i <= x; i++) {
result *= i;
}
// do staff end
return result;
}
先进行升序排序,然后把需要的 7, 5, 3 从数组里取出来,然后按要求合并。
sticky,见 https://developer.mozilla.org/en-US/docs/Web/CSS/position#sticky
- #A { z-index: 50; }
- 无需改动
- ...
- 方式一用的应该是事件冒泡的原理吧,方式二是直接绑定到元素上。
- 没做过测试,不好下结论。
- 方式一对于在 .btn 经常变化(元素增删)时,比较好点。
function Animal(props) {
this.name = props.name;
// do staff begin
this.say = function () {
};
// BTW,这种做并不好,弄脏了实例
Animal.__instances__.push(this);
// do staff end
}
// do staff begin
Animal.prototype.say = function () {
};
Animal.die = function (animal) {
animal.die = true;
};
Animal.all = function () {
return Animal.__instances__.filter(function _(animal) {
return !animal.die;
});
};
Animal.__instances__ = [];
// do staff end
var animalA = new Animal({ name: '小白鼠A' });
var animalB = new Animal({ name: '小白鼠B' });
class Animal {
constructor() {
this.name = props.name;
// do staff begin
this.say = function () {
};
// BTW,这种做并不好,弄脏了实例
Animal.__instances__.push(this);
// do staff end
}
say() {
}
static die(animal) {
animal.die = true;
}
static all() {
return Animal.__instances__.filter(animal => !animal.die);
}
}
Animal.__instances__ = [];
var animalA = new Animal({ name: '小白鼠A' });
var animalB = new Animal({ name: '小白鼠B' });
/https?:\/\/(?:[^\/]*)(\/(?:[^?#])*)/i
border-box width, height 会包括 border-width 和 padding content-box width, height 不包括 border-width 和 padding
https://www.w3.org/TR/CSS2/cascade.html#specificity
根据 username 在数据库中找出 hash 和 salt 字段,使用 password 和 salt 进行加密 hash 运算,得出的结果与取出来的 hash 字段进行比较。
- 需要一个图形验证码接口、一个短信验证码接口
- 可以把对应的 token (或 session)设置失效时间
直接 throw 出一个异常,或 return 一个 reject 对象。
先判断第一个与最后一个数,如果第一个数小于最后一个数,则第一个数为最小值; 然后通过比较前一个与后一个数,如果前一个数大于后一个数,则后一个数为最小值。