This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function useAfterPaintEffect(effect, dependencies) { | |
useEffect(() => { | |
requestAnimationFrame(() => { | |
setTimeout(() => { | |
effect(); | |
}, 0); | |
}); | |
}, dependencies); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function min(...values) { | |
if (values.length < 1) { | |
return Infinity; | |
} | |
let minValue = values.shift(); | |
for (const value of values) { | |
if (value < minValue) { | |
minValue = value; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'Brave New World'.split('New').join('Old') | |
// "Brave Old World" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const amount = new Intl.NumberFormat('id-ID', { | |
style: 'currency', | |
currency: 'IDR' | |
}).format("15000"); | |
console.log(amount); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
<div id="qrcode"></div> | |
<script src="https://cdn.jsdelivr.net/gh/davidshimjs/qrcodejs/qrcode.min.js"></script> | |
<script> | |
const qrcode = new QRCode(document.getElementById('qrcode'), { | |
text: 'http://jindo.dev.naver.com/collie', | |
width: 128, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const style = { | |
width: 400, | |
height: 300, | |
position: 'fixed', | |
top: 900, | |
left: 60, | |
'z-index': 1234 | |
} | |
const inline = Object.entries(style).reduce((prev, curr) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Product(name, price) { | |
this.name = name; | |
this.price = price; | |
} | |
function Food(name, price) { | |
Product.call(this, name, price); | |
this.category = 'food'; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
import { ref, watch } from 'vue' | |
export default { | |
props: { | |
totalPages: Number, | |
currentPage: Number, | |
}, | |
setup(props) { | |
let numShown = 5; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// convert objec to a query string | |
const qs = Object.keys(params) | |
.map(key => `${key}=${params[key]}`) | |
.join('&'); | |
// OR | |
var queryString = Object.keys(params).map((key) => { | |
return encodeURIComponent(key) + '=' + encodeURIComponent(params[key]) | |
}).join('&'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* target IE 6 and 7 */ | |
@media screen\9 { | |
/* custom style */ | |
} | |
/* target IE 6, 7 and 8 */ | |
@media \0screen\,screen\9 { | |
/* custom style */ | |
} |
NewerOlder