Tips & Tutorials

How To Move & Copy Files In NodeJS – Simple Examples

Welcome to a tutorial on how to move and copy files in NodeJS. Need to back up some files in NodeJS? Move some old files to another folder? To copy a file in NodeJS – require(“fs”).copyFileSync(“SOURCE”, “TARGET”) To move a file in NodeJS require(“fs”).renameSync(“SOURCE”, “TARGET”) That covers the quick basics, but read on if you …

How To Move & Copy Files In NodeJS – Simple Examples Read More »

Javascript Loops & Iterations Cheat Sheet – Simple Examples

Welcome to a beginner’s tutorial on Javascript loops and iterations. Want to loop through arrays, objects, or do things repetitively? The common mechanisms to loop and iterate in Javascript are: For – for (let i=0; i<10; i++) { … } For-In – for (let key in object) { … } For-Of – for (let element of …

Javascript Loops & Iterations Cheat Sheet – Simple Examples Read More »

Delete Files & Folders In NodeJS – Simple Examples

Welcome to a quick tutorial on how to delete files and folders in NodeJS. Need to remove some old or temporary files in Node? To delete files in NodeJS, we can use the unlink function. const fs = require(“fs”) fs.unlink(“PATH/FILE”, (error) => {}) fs.unlinkSync(“PATH/FILE”) To delete (empty) folders in NodeJS, we can use the rmdir …

Delete Files & Folders In NodeJS – Simple Examples Read More »

How Javascript Files Load (Normal vs Async vs Defer)

Welcome to a quick tutorial on how Javascript files are loaded – Normal, async, and defer. Ever since day one of learning Javascript, we were taught to either code Javascript inline or load them from external files. But just how are these Javascript files loaded? This simple question has somehow eluded many beginners, and in short …

How Javascript Files Load (Normal vs Async vs Defer) Read More »

Set & Get HTML Data Attributes In Javascript (Simple Examples)

Welcome to a quick tutorial on how to set and get HTML data attributes in Javascript. Want to insert your own custom property or data into HTML elements? To set HTML data attributes, we simply define data-KEY=”VALUE” in the opening tag. For example, <div data-color=”red”> We can also set HTML data attributes in Javascript using …

Set & Get HTML Data Attributes In Javascript (Simple Examples) Read More »

Get Set Remove HREF In Javascript – Simple Examples

Welcome to a quick tutorial on how to get, set, and remove the href property in Javascript. By now, you should know href very well. That “thing” we use to specify which webpage to link to. But how can we dynamically change or remove it using Javascript? For a quick answer: To get the href …

Get Set Remove HREF In Javascript – Simple Examples Read More »