ใช้ Object.assign ตั้งค่าให้ stylesheet เพื่อให้โค้ดดูสะอาดขึ้น
CSSJavascript
อัพเดทล่าสุด 19 ก.ย. 64

จากเดิมโค้ดประมาณนี้

dom.style.left = left + 'px'
dom.style.top = top + 'px'
dom.style.width = width + 'px'
dom.style.height = height + 'px'

เราสามารถที่จะใช้ Object.assign เพื่อทำให้โค้ดเหลือแค่นี้ได้

Object.assign(dom.style, { left: left + 'px', top: top + 'px', width: width + 'px', height: height + 'px' })

สั้นลงบานเลย

Beta Version v23.12.4 : ขออภัยเว็บกำลังก่อสร้าง (อีกแล้ว) แต่คราวนี้กำลังสร้างจริงจังละ