Vinh La Kiến

48 bundles
4 files8 months ago
1

Topic 1

typeof

1234567891011121314
// C++ #include <iostream> using namespace std; int main() { cout << "${firstName + " " + lastName} Hello Everybody!"; return 0; } // JavaScript console.log("${firstName + " " + lastName} in the first time share your dev story!"); // Python print("Good luck!")

Is valid date

12345678910111213141516171819202122232425262728
let day = 31; let month = 12; let year = 2019; let isValid = false; let isLeapYear = year % 400 == 0 || (year % 4 == 0 && year % 100 != 0); let maxDay = 0; switch (month) { case 1: case 3: case 5: case 7: case 8: case 10: case 12: maxDay = 31; break; case 4: case 6: case 9: case 11: maxDay = 30; case 2: maxDay = isLeapYear ? 29 : 28; } isValid = maxDay != 0 && day >= 1 && day <= maxDay;

for in Js

1234567891011
let uids = [1, 2, 3, 4, 5, 6]; let targets = ['profile', 'group', 'page']; let features = ['invited', 'like']; for (let uid of uids) { for (let target of targets) { for (let feature of features) { // uid, target, feature } } }

Promise

1234567891011121314151617
import * as fs from "fs"; function myReadFile(path) { return new Promise((res, rej) => { fs.readFile(path, (err, data) => { if (err) rej(err); res(data); }); }); } myReadFile("data1.txt") .then((value) => { }); console.log("END");