| Boolean
                        
                                                                                    
                                                                                            | Type conversion | Tự động ép kiểu |  
                                                                                            | Type coercion | Ép kiểu ngầm |  
                                                                                            | Truthy |  
                                                                                            | Falsy |  
                                                                                            | Logical operators |  Number
                        
                                                                                    
                                                                                            | Number.parseInt('1.5') | 1 |  
                                                                                            | Number.parseFloat('1.5') | 1.5 => cả parseInt và parseFloat luôn parse từ trái sang phải đến khi có lỗi |  
                                                                                            | n.toFixed |  
                                                                                            | n.toPrecision | Làm tròn đến chữ số có nghĩa (bao gồm cả số nguyên và thập phân) |  Math
                        
                                                                                    
                                                                                            | Math.PI |  
                                                                                            | Math.SQRT2 | Căn bậc 2 |  
                                                                                            | Math.ceil(x) | Làm tròn lên |  
                                                                                            | Math.floor(x) | làm tròn xuống |  
                                                                                            | Math.round(x) | Làm tròn như bình thường |  
                                                                                            | Math.trunc(x) | Lấy nguyên bỏ thập phân |  
                                                                                            | Math.random() | Random số thực từ 0->1 |  
                                                                                            | Math.abs(x) |  
                                                                                            | Math.pow(x, y) |  
                                                                                            | Math.sqrt(x) |  
                                                                                            | Số thực không so sánh bằng được |  Object
                        
                                                                                    
                                                                                            | delete key | delete student.name |  
                                                                                            | property value shorthand | { id: id} => { id } |  
                                                                                            | in | 'name' in student |  
                                                                                            | clone object | Object.assign hoặc ... (spread opertator) |  
                                                                                            | Clone chỉ 1 tầng, con của object không có clone ra => Nên sử dụng thư viện cho clone |  
                                                                                            | Objec.keys | for ... in  (duyệt key) |  ES6
                        
                                                                                    
                                                                                            | strict mode | sử dụng ES5 hoặc không |  
                                                                                            | hoisting | đem var và định nghĩa hàm (chỉ function declaration không phải arrow function) lên đầu file |  
                                                                                            | IIFE | thực hiện function ngay sau khi định nghĩa |  
                                                                                            | closures | hàm con sử dụng biến của hàm con ngay cả khi hàm cha đã kết thúc |  
                                                                                            | Rest parameter | dấu ... |  
                                                                                            | Arrow function | () => {} |  
                                                                                            | Curry function | hàm return về 1 function khác |  
                                                                                            | Enhand Object Property |  
                                                                                            | Property shorthand | { id: id } => { id } |  
                                                                                            | computed property name | []  Ex: student['name'] |  
                                                                                            | methor property |  
                                                                                            | destructuring | rút trích property |  
                                                                                            | Object.assign |  
                                                                                            | this |  
                                                                                            | call |  
                                                                                            | apply |  
                                                                                            | bind | bind this cho 1 object cụ thể |  
                                                                                            | Protocol |  
                                                                                            | iteration protocol | Chuẩn cho for ... of |  |  | String
                        
                                                                                    
                                                                                            | Dấu backticks | `My ${name}` |  
                                                                                            | String sinh ra đã cố định không thay đổi được giá trị |  
                                                                                            | text.length |  
                                                                                            | .toLowerCase() |  
                                                                                            | .toUpperCase() |  
                                                                                            | .indexOf |  
                                                                                            | .lastIndexOf |  
                                                                                            | .startWith |  
                                                                                            | .includes |  
                                                                                            | .endsWith |  
                                                                                            | .slice(start, end) |  
                                                                                            | .substring(start, end) |  
                                                                                            | .replace |  
                                                                                            | .replaceAll |  
                                                                                            | .split() |  
                                                                                            | .join() |  
                                                                                            | Kí tự ellipsis '...' => \u2026 |  Array
                        
                                                                                    
                                                                                            | Array.isArray(arr) |  
                                                                                            | Tồn tại phần tử |  
                                                                                            | every(callback) |  
                                                                                            | some (callback) |  
                                                                                            | indexOf |  
                                                                                            | lastIndexOf |  
                                                                                            | includes |  
                                                                                            | find |  
                                                                                            | findIndex |  
                                                                                            | Thêm/Xóa phần tử |  
                                                                                            | push |  
                                                                                            | pop |  
                                                                                            | shift |  
                                                                                            | unshift |  
                                                                                            | slice |  
                                                                                            | Duyệt mảng |  
                                                                                            | .forEach |  
                                                                                            | for of |  
                                                                                            | map |  
                                                                                            | filter |  
                                                                                            | slice |  
                                                                                            | reduce |  
                                                                                            | fill |  
                                                                                            | join |  
                                                                                            | concat |  
                                                                                            | reverse |  
                                                                                            | sort |  Lập trình bất đồng bộ
                        
                                                                                    
                                                                                            | setTimeout | lưu ý với this |  
                                                                                            | debounce | Đợi cho đến khi không còn gọi nó nữa thì thực hiện |  
                                                                                            | throttle | Trong bao nhiêu milisecond sẽ chỉ trigger 1 lần |  
                                                                                            | setInterval |  
                                                                                            | EventLoop | Quan trọng |  
                                                                                            | Ajax | XMLHttpRequest |  
                                                                                            |  | RestApi |  
                                                                                            | Promise | Fix callback hell |  
                                                                                            |  | method |  
                                                                                            | Promise chaining | .then nhiều lần |  
                                                                                            | Fetch |  
                                                                                            | CSP | Content Security Policy |  
                                                                                            | CORS | Cross-Ỏigin Resource Sharing |  
                                                                                            | Async function |  
                                                                                            | Top level await |  
                                                                                            | JSON |  
                                                                                            | JSON.parse(text) | parse text thành biến js (có một số trường hợp bị lỗi) |  
                                                                                            | JSON.stringify(json) | parse biến js thành text |  |  | ESMAScript 2016 => 2022
                        
                                                                                    
                                                                                            | 2016 |  
                                                                                            | includes |  
                                                                                            | ** | Lũy thừa |  
                                                                                            | 2017 |  
                                                                                            | Async function |  
                                                                                            | Shared memory and atomics |  
                                                                                            | String padding | padStart, padEnd |  
                                                                                            | Object.value | Lấy value của object => array |  
                                                                                            | Object.keys | Lấy keys => array |  
                                                                                            | Object.entries | Lấy cả key và value |  
                                                                                            | Object.getOwnPropertyDescription |  
                                                                                            | Trailing Commas |  
                                                                                            | 2018 |  
                                                                                            | Rest/Spread properties for object  | dấu ... |  
                                                                                            | for await of |  
                                                                                            | finally() |  
                                                                                            | Regular expression |  
                                                                                            | 2019 |  
                                                                                            | flat, flatMap | hạ cấp mảng |  
                                                                                            | Object.fromEntries |  
                                                                                            | trimStart, trimEnd |  
                                                                                            | Optional catch binding | catch không cần truyền param error |  
                                                                                            | sort() | Giữ thứ tự những phần tử giống nhau |  
                                                                                            | toString() |  
                                                                                            | 2020 |  
                                                                                            | Thêm kiểu dữ liệu BigInt |  
                                                                                            | Dynamic import | import trong function lúc nào xài nó không phải import trên đầu |  
                                                                                            | Nullish coalescing | ?? null và undefined mới tính lấy cái sau |  
                                                                                            | optional chaining | ?. Ex: student?.name |  
                                                                                            | globalThis |  
                                                                                            | Module namespace export | Thay vì import * rồi export thì giờ có thể export trên 1 dòng |  
                                                                                            | for in |  
                                                                                            | import.meta |  
                                                                                            | 2021 |  
                                                                                            | Logical asignment | ||=  &&=  ??= |  
                                                                                            | Numberic operator | 1_000_000  nhìn dễ hơn |  
                                                                                            | replaceAll |  
                                                                                            | promise.any |  
                                                                                            | 2022 |  
                                                                                            | Top-level await |  
                                                                                            | private class |  
                                                                                            | Object.hasOwn |  API và Postman
                        
                                                                                    
                                                                                            | Json Server | cung cấp database dạng json sẽ tự tạo được api |  
                                                                                            | Browser | global object là window |  Web APIs
                        
                                                                                    
                                                                                            | Browser URL |  
                                                                                            | window.location.href | có thể redirect và có thể back lại trang trước đó => recomment sử dụng lấy url hiện tại |  
                                                                                            | window.location.replace | redirect nhưng không back lại được trang trước đó |  
                                                                                            | window.location.assign | di chuyển qua trang mới, recomment sử dụng cái này không sử dụng href |  
                                                                                            | Console API |  
                                                                                            | Log variations | log, info, debug, warn, error |  
                                                                                            | Multiple values | Với string ``:
 + %o => object
 
 + %s => string
 
 + %i => integer
 
 + %f => float
 |  
                                                                                            | Assert | show message khi condition là false |  
                                                                                            | Counting |  
                                                                                            | Track time | time, timeLog, timeEnd |  
                                                                                            | Groups | group, groupEnd, groupCollapsed |  
                                                                                            | Stack trace |  
                                                                                            | Tables |  
                                                                                            | Styles | sử dụng %c |  
                                                                                            | Clear |  
                                                                                            | Storage API |  
                                                                                            | Storage Interface | getItem, setItem, removeItem, clear |  
                                                                                            |  | - LocalStorage, SessionStorage, hay cookie,… phải parse string rồi mới lưu- LocalStorage => đóng tab hay đóng trình duyệt vẫn còn
 - SessionStorage => đóng tab sẽ mất
 |  
                                                                                            | Browser Network |  | 
            
Created By
Metadata
Comments
No comments yet. Add yours below!
Add a Comment
Related Cheat Sheets
More Cheat Sheets by tronghao