Tips & Tutorials – Javascript

How To Create A Grid In Javascript (Simple Examples)

Welcome to a quick tutorial on how to create a grid in Javascript. Need to display some data in a nice grid? Gone are the good old days where we have to use crazy tables and CSS hacks. To create a grid in Javascript: Define an HTML grid container. <div id=”grid”></div> #grid { display: grid; grid-template-columns: …

How To Create A Grid In Javascript (Simple Examples) Read More »

How To Use Javascript Workers (Very Simple Example)

Welcome to a tutorial and example on how to use Javascript workers. So you have heard of Javascript workers and their “threading powers”. But just how do we create and use Javascript workers? Using Javascript workers is somewhat similar to performing an AJAX call to a server-side script. We send data to a worker to …

How To Use Javascript Workers (Very Simple Example) Read More »

3 Ways To Display Error Messages In Javascript (Simple Examples)

Welcome to a quick tutorial on how to display error messages in Javascript. Just started with Javascript and wondering where the error messages went? Or looking for ways to better deal with error notifications? The common ways to show error messages in Javascript are: Error messages will show in the developer’s console by default. In …

3 Ways To Display Error Messages In Javascript (Simple Examples) Read More »

3 Ways To Write Files In NodeJS (Sync, Async, Stream)

Welcome to a quick tutorial and examples on how to write files in NodeJS. Want to create, write, and append to files in NodeJS? It is sadly not that straightforward. The common ways to write a file in NodeJS are: Write and append to files asynchronously. require(“fs”).writeFile(“FILE.TXT”, “TEXT”, (err)=>{}); require(“fs”).appendFile(“FILE.TXT”, “TEXT”, (err)=>{}); Write and append …

3 Ways To Write Files In NodeJS (Sync, Async, Stream) Read More »

Checking Javascript Version (Why It Makes No Sense)

So you are looking for ways to check the Javascript version, add some compatibility checks to your project? “Javascript version” can refer to any of the following in the modern-day: ECMA International now handles the recommended standards for the development of Javascript – ECMAScript 1st edition (ES1), ECMAScript 2nd edition (ES2), etc… Every company has …

Checking Javascript Version (Why It Makes No Sense) Read More »

5 Ways To Create & Save Files In Javascript (Simple Examples)

Welcome to a tutorial on how to create and save files in Javascript. Well, this will be kind of a complicated process for beginners. To keep things simple – Saving files on server-side NodeJS is a breeze, but it is tricky to directly save files on the client-side because of security restrictions. That said, there …

5 Ways To Create & Save Files In Javascript (Simple Examples) Read More »

5 Ways To Read Files In NodeJS (To String, Line-by-Line, Array)

Welcome to a quick tutorial and examples on how to read files in NodeJS. Reading files, just how difficult can it be? Well, brace yourselves. It’s not that straightforward apparently. The common ways to read files in NodeJS are: To read the entire file into a string asynchronously – require(“fs”).readFile(“FILE.TXT”, “utf8”, (err, data) => { …

5 Ways To Read Files In NodeJS (To String, Line-by-Line, Array) Read More »

5 Ways To Add Elements To Javascript Array (Simple Examples)

Welcome to a quick tutorial on how to add elements to a Javascript array. New to Javascript and the whole array thing? Yes, creating a new array is straightforward, but it can be quite confusing when it comes to adding elements to an existing one. There are a couple of different ways to add elements …

5 Ways To Add Elements To Javascript Array (Simple Examples) Read More »