覚えたこと
someとevery
const isAdult = people.some(person => new Date()).getFullYear() - person.year >= 19)
const allAdult = people.every(person => new Date()).getFullYear() - person.year >= 19)
findとfindInex
findIndexとslice
const index = comments.findIndex(item => {
return item.id === 823423
})
//comments.splice(index,1);これでもいい
const newComments = [
...comments.slice(0,index),
...comments.slice(index +1 )
];
canvas
const canvas = document.querySelector('#draw');
const ctx = canvas.getContext('2d');
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
ctx.strokeStyle = '#bada55';
ctx.lineJoin = 'round';
ctx.lineCap = 'round';
マウスで描写
let isDrawing = false;
function draw(e) {
if(!isDrawing) return;
console.log(e)
}
canvas.addEventListener('mousemove', draw);
canvas.addEventListener('mousedown', () => isDrawing = true);
canvas.addEventListener('mouseup', () => isDrawing = false);
canvas.addEventListener('mouseout', () => isDrawing = false);
ーーーーーーーーーーーーーーーーーーーーーーーー
参考