0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

javascript演習 6,7日目/30日

Posted at

覚えたこと

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);

ーーーーーーーーーーーーーーーーーーーーーーーー

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?