본문 바로가기

html | javascript

(28)
html javascript - check canvas mousedown mouse pos: " data-ke-type="html">HTML 삽입미리보기할 수 없는 소스
html javascript - element dataset test dataset test dataset 1
html javascript - array remove (splice) const arr0 = [0,1,2,3,4,5,6,7]const arr1 = arr0.splice(1,3)console.log(arr0) // [0,4,5,6,7]console.log(arr1) // [1,2,3]const arr2 = ['O', 'I', 'II', 'III', 'IV', 'V', 'VI']arr2.splice(1, 0, 'a') // insertconsole.log(arr2) // ['O', 'a', 'I', 'II', 'III', 'IV', 'V', 'VI']arr2.splice(4, 1, 'b') // replaceconsole.log(arr2) // ['O', 'a', 'I', 'II', 'b', 'IV', 'V', 'VI']const arr3 = [ { name: 'arr..
html javascript - array filter const arr0 = ['car','bus','aircraft','spacecraft','car1','motorcycle','car'] const arr1 = [ {name: 'car', type: 'land', cost: 100}, {name: 'bus', type: 'land', cost: 50}, {name: 'aircraft', type: 'sky', cost: 200}, {name: 'motorcycle', type: 'land', cost: 80}, {name: 'spacecraft', type: 'space', cost: 1000}]const arr2 = [5,3,21,6,50,100,1,10,12,20,2]const filter0 = arr0.filter(str => s..
html javascript - canvas to png, jpg file function savePng(canvas, name) { saveImage(canvas.toDataURL('image/png'), name, 'png')}function saveJpg(canvas, name) { saveImage(canvas.toDataURL('image/jpg'), name, 'jpg')}function saveImage(dataUrl, name, type) { const link = document.createElement('a') link.href = dataUrl link.download = `${name}.${type}` link.click() URL.revokeObjectURL(link.href)}
html javascript - canvas imageData const canvas = document.createElement('canvas')canvas.width = 200canvas.height = 200document.body.appendChild(canvas)const ctx = canvas.getContext('2d')const imgData = ctx.createImageData(100, 100)for (let i=0; i
html javascript - array, object copy const obj = {name: 'obj'}const list = [obj]const obj1 = structuredClone(obj)obj1.name = 'obj 1'const list1 = structuredClone(list)list1[0].name = 'list 1 obj'const obj2 = Object.create(obj)obj2.name = 'obj 2'const list2 = Array.from(Object.create(list))list2[0].name = 'list 2 obj'console.log(list1[0] === obj) // falseconsole.log(list2[0] === obj) // trueconsole.log(obj) // { name: 'list 2 obj' }..
html javascript - easing circular