https://kknews.cc/zh-tw/finance/zpxln2q.html [開發經驗分享][JavaScript]浮點數運算出現一堆小數位數 https://dotblogs.com.tw/WillianHsiaoDotNetBLog/2020/01/15/JavascriptFloatCaculateBug?fbclid=IwAR0SnYG7FnesbfENWCsOT_ceGxqab6Q1dksJ3qIr-pe65m55wNBlWLc0Ns0 精確的浮點數運算 ? https://medium.com/pyladies-taiwan/%E7%B2%BE%E7%A2%BA%E7%9A%84%E6%B5%AE%E9%BB%9E%E6%95%B8%E9%81%8B%E7%AE%97-28d34e652e51
https://stackoverflow.com/questions/784929/what-is-the-not-not-operator-in-javascript
https://stackoverflow.com/questions/29312123/how-does-the-double-exclamation-work-in-javascript
value
!value
!!value
false
true
false true
false true
null
true false undefined
true false 0
true false -0
true false 1
false
true -5
false true NaN
true false ''
true false ‘hello’
true false
https://stackoverflow.com/questions/6600868/set-default-value-of-javascript-object-attributes```
// default num: 0, unit: ‘pics’
function items(op) {
const { num, unit } = Object.assign({}, { num: 0, unit: ‘pics’}, op);
}
https://1loc.dev/
const bookListsQuery = await modules.firestore.collection('books') .get(); const sortedObj = Object.values(bookListsQuery.docs).sort(function(a, b){ console.log('a %s b %s', a.data().order, b.data().order) return Number(a.data().order) > Number(b.data().order); }); sortedObj.forEach(function(doc){ console.log(doc.data()) }); other way object use map to array, then it sorted.
const bookListsQuery = await modules.firestore.collection('books') .get(); const sortedArr = bookListsQuery.docs.map(function (doc) { // 轉換成array return doc.data() }); sortedArr.sort(function compare(a, b) { return a.order > b.order; // 升 小->大 }); sortedArr.forEach(function(data){ console.log(data.data()) }) ==========
console.log(‘show value string, object %s %O’, var.string, var.object);