Skip to content

Instantly share code, notes, and snippets.

View showlovezz's full-sized avatar

vita hsieh showlovezz

  • Taiwan
View GitHub Profile
{
"editor.suggestSelection": "first",
"vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
// Prettier 套件格式啟動
"editor.defaultFormatter": "esbenp.prettier-vscode",
// Tab 間隔
"editor.tabSize": 2,
// Sass 套件 打開
"sass.lint.enable": true,
// 字體大小
@showlovezz
showlovezz / exampleArray2.js
Last active April 23, 2020 01:19
鼠年全馬鐵人挑戰 - Array Example
// 這是一個 DataTable 的表格,最左邊欄位會有 checkboxes,可以讓 User 複選。
export const tableSelectRow = (selectedEDILogIdList) => ({
mode: 'checkbox',
selectionHeaderRenderer: renderSelectionHeader,
selectionRenderer: renderSelection,
style: { backgroundColor: '#c8e6c9' },
onSelect: (row, isSelect) => {
if (isSelect) {
// 這裡使用到 array 的 push 語法,意思是點選到該 row 時,把該 row 的 id,放到該陣列末端。
selectedEDILogIdList.current.push(row.id)
@showlovezz
showlovezz / exampleArray1.js
Last active April 23, 2020 01:02
鼠年全馬鐵人挑戰 - Array Example
// 撇開 React 相關的語法,在這裡很常使用 array.length 陣列長度,來判斷某些事情及達到什麼事情。
const handleReprocess = useCallback(() => {
// 是指該陣列長度不為 0 的話,就跳出 SweetAlert confirm 的視窗。
if (selectedEDILogIdList.current.length !== 0) {
SweetAlert.confirm({
text: 'You really want to Reprocess it !?',
timer: 3000,
callback: () => {
return dispatch(reprocessEDILogIds(selectedEDILogIdList.current))
}
@showlovezz
showlovezz / arrayFilter.js
Created April 22, 2020 01:07
鼠年全馬鐵人挑戰 - Array Filter
var number = [4, 9, 14, 19]
var result = number.filter((value, index, array) => {
return (value % 2 === 1) // % 為餘數運算子
})
console.log(result) // 會得到 [9, 19]
@showlovezz
showlovezz / arrayMap.js
Last active April 22, 2020 01:04
鼠年全馬鐵人挑戰 - Array Map
var number = [2, 3, 4, 5]
var result = number.map((value, index, array) => {
return (value + value)
})
console.log(result) // 會得到 [4, 6, 8, 10]
@showlovezz
showlovezz / array3.js
Created April 20, 2020 16:19
鼠年全馬鐵人挑戰 - Array
var ary1 = ['TRCK', 'MOP', 'CFS', 'WMS']
var ary2 = ['APPLE', 'MGF', 'AMAT', 'ACER', 'WURTH']
console.log(ary1.length) // 會得到 4
console.log(ary2.length) // 會得到 5
console.log(Array.isArray(ary1)) // 會得到 true
console.log(ary1.concat(ary2)) // 會得到 ['TRCK', 'MOP', 'CFS', 'WMS', 'APPLE', 'MGF', 'AMAT', 'ACER', 'WURTH']
@showlovezz
showlovezz / array2.js
Created April 20, 2020 01:06
鼠年全馬鐵人挑戰 - Array
var data = ['MOP', 'CFS', 'WMS', ['AMAT', 'WURTH', 'MGF'], 'TMS']
console.log(data[3][0]) // 會取得 AMAT (會取得第 3 個元素的第 1 個元素)
console.log(data[3][2]) // 會取得 MGF (會取得第 3 個元素的第 3 個元素)
console.log(data[3][3]) // 會取得 undefined (因為第 3 個元素的第 4 個元素不存在)
@showlovezz
showlovezz / array.js
Last active April 20, 2020 01:05
鼠年全馬鐵人挑戰 - Array
var data = ['MOP', 'CFS', 'WMS', 'TRCK', 'TMS']
console.log(data[0]) // 會取得 MOP (取得索引值為 0,也就是第 1 個元素)
console.log(data[2]) // 會取得 WMS (取得索引值為 2,也就是第 3 個元素)
@showlovezz
showlovezz / switch.js
Created March 15, 2020 11:06
鼠年全馬鐵人挑戰 - 6-11
// 基本 switch 指令介紹
switch (條件式) {
case 1:
符合 「條件式 = 值 1」時要執行的指令 (區塊)
case 2:
符合 「條件式 = 值 2」時要執行的指令 (區塊)
...
default:
以上全部條件式都不符合時執行此指令 (區塊)
}
@showlovezz
showlovezz / ifElse.js
Created March 15, 2020 10:28
鼠年全馬鐵人挑戰 - 6-10
// 基本 if else 指令介紹
if (條件式 1) {
條件式為 1 為 true 時執行此指令區塊
} else if (條件式 2) {
條件式為 2 為 false 時執行此指令區塊
}
...
} else {
以上全部條件都為 false 時執行此指令區塊
}