Webstorm 以红色突出显示箭头函数并说明Expression statement is not assignment or call要做什么?
主页
/
user-32977
Darth's questions
遇到这样的问题。有一个类extends Array需要清除。
class Grid extends Array {
constructor(board){
super();
// условное содержимое -
this.push([{x:0,y:0}][{x:0,y:1}],[{x:1,y:0}][{x:1,y:1}]);
console.log('grid constructed');
this.ctx = board.layers.grid; //очень нужная вещь без которой ничего не работает
}
clear(){
this.splice(0, this.length);
}
}
const grid = new Grid({layers:{grid:'2d)'}});
grid.clear();// oops..
可以做什么?
有一个字符串数组(数据库中的字段,它们带有下划线)。该对象具有完全相同的一组字段,但有一个细微差别 - 而不是 orthodox_lower_underline,而是一种类似粥的 CamelCase。任务是遍历数组,并从中收集对象对应值的数组。
想这样做:
const params = [
'field_one',
'field_two',
'justfield',
'field_three',
'longer_than_one_field'
];
const data = {
fieldOne:1,
fieldTwo:2,
justfield:'d',
fieldThree:3,
longer_than_one_field:'____'
}
params.map(key => data[key.replace(/_(.)/g, '$1')]);
但我不知道如何更改寄存器 $1。