• Nov 19, 2022 •CodeCatch
0 likes • 3 views
const flat = arr => [].concat.apply([], arr.map(a => Array.isArray(a) ? flat(a) : a)); // Or const flat = arr => arr.reduce((a, b) => Array.isArray(b) ? [...a, ...flat(b)] : [...a, b], []); // Or // See the browser compatibility at https://caniuse.com/#feat=array-flat const flat = arr => arr.flat(); // Example flat(['cat', ['lion', 'tiger']]); // ['cat', 'lion', 'tiger']
0 likes • 2 views
// `arr` is an array const clone = arr => arr.slice(0); // Or const clone = arr => [...arr]; // Or const clone = arr => Array.from(arr); // Or const clone = arr => arr.map(x => x); // Or const clone = arr => JSON.parse(JSON.stringify(arr)); // Or const clone = arr => arr.concat([]);
• Nov 18, 2022 •AustinLeath
0 likes • 0 views
// Get the text that the user has selected const getSelectedText = () => window.getSelection().toString(); getSelectedText();
var d = new Date(); var d = new Date(milliseconds); var d = new Date(dateString); var d = new Date(year, month, day, hours, minutes, seconds, milliseconds);
• Mar 11, 2021 •C S
1 like • 1 view
if (process.env.NODE_ENV === "production") { app.use(express.static("client/build")); app.get("*", (req, res) => { res.sendFile(path.resolve(__dirname, "client", "build", "index.html")); }); }
• Aug 2, 2025 •hasnaoui1
0 likes • 1 view
console.log("xa")