Category

Programming Tutorials and Coding Guides

Explore programming tutorials with practical examples across multiple languages, scripting, and development concepts for beginners and advanced users.

Welcome to the Programming tutorials section, where you will learn coding concepts with real-world examples across multiple languages and platforms.

This category includes beginner to advanced guides covering scripting, automation, and application development in Java, JavaScript, Python, Go, TypeScript, and related stacks.

Whether you are learning programming for system administration or building applications, browse the articles below for practical examples and language-specific references.

Programming plays a crucial role in modern infrastructure and DevOps workflows. You can also explore DevOps and Linux to see how code integrates with system-level operations.

956 articles

Programming category illustration with code editor, automation, and debugging graphics
programming

JavaScript copy to clipboard (navigator.clipboard.writeText, secure context)

Copy text to the clipboard with navigator.clipboard.writeText, secure contexts, NotAllowedError, readText, and why execCommand is legacy. Node uses a stub clipboard in examples so snippets run; browsers need HTTPS and …

Olorunfemi Akinlua4 min read
programming

JavaScript clone object (shallow spread, structuredClone, JSON)

Clone objects in JavaScript: shallow spread and Object.assign, for...in, Object.create + descriptors, JSON limits, structuredClone and DataCloneError, and circular refs. Runnable Node snippets with short output notes; …

Olorunfemi Akinlua5 min read
programming

JavaScript classes tutorial (constructor, methods, static, extends)

JavaScript classes: constructor, instance methods, getters, static methods, extends and super, public fields, and private # fields. Runnable Node snippets with short expected-output notes; links to ranges and cloning …

Olorunfemi Akinlua5 min read
programming

jQuery check if checkbox is checked (and JavaScript checked property)

Read checkbox state with HTMLInputElement.checked, jQuery .prop('checked') and .is(':checked'), why .attr('checked') misleads, and change events. Snippets use `{run=false}`—run in DevTools or with jsdom + jQuery 3.7; …

Steve Alila4 min read
programming

JavaScript check if undefined (typeof, ===, void 0, nullish)

Check undefined in JavaScript: typeof for undeclared names, === undefined for declared bindings, falsy vs undefined, == null, void 0, and nullish coalescing (??) for defaults. Runnable Node snippets with short output …

Olorunfemi Akinlua4 min read
programming

JavaScript check if string is number (Number.isFinite, isNaN, parseInt)

Validate numeric strings in JavaScript: whole-token checks with trim + Number.isFinite, global isNaN pitfalls, parseInt prefix behavior, integers, strict regex decimals, and digits-in-text vs fully numeric. Runnable Node …

Olorunfemi Akinlua5 min read
programming

JavaScript check if string contains space or whitespace (indexOf, RegExp, trim)

Check if a string contains spaces in JavaScript: literal U+0020 vs Unicode whitespace, indexOf and includes, RegExp \s, trim for ends-only emptiness, and NBSP (U+00A0) pitfalls. Runnable Node snippets with short …

Olorunfemi Akinlua4 min read
programming

JavaScript double exclamation mark (!!): boolean coercion

JavaScript double exclamation (!!) vs Boolean(): same boolean coercion to true/false, truthy and falsy lists, TypeScript idiom, and why [] is truthy. Runnable Node snippets with short output notes.

Olorunfemi Akinlua5 min read
programming

JavaScript double question mark (??): nullish coalescing

JavaScript double question mark (??) is nullish coalescing: defaults only for null or undefined, unlike ||. Covers chaining, mixing with ||/&& (parentheses), and examples where 0 and empty string must be preserved. …

Olorunfemi Akinlua5 min read
programming

Cannot use import statement outside a module

Fix SyntaxError cannot use import statement outside a module in Node.js, browsers, and AWS Lambda. Use type module, .mjs, script type=module, and avoid ERR_MODULE_NOT_FOUND confusion—with Node-tested output.

Deepak Prasad6 min read
programming

JavaScript findIndex: array findIndex and objects by property

findIndex javascript and js findIndex: predicate scan with Array.prototype.findIndex, return index or -1, optional thisArg, javascript find index of object in array by property, and how findIndex differs from find and …

Olorunfemi Akinlua4 min read
programming

Compare strings in JavaScript: ===, localeCompare, and case-insensitive matches

JavaScript string compare and string equals with === vs ==, localeCompare and Intl.Collator for locale-aware sorting, case-insensitive patterns, trim and Unicode normalize—with example console output.

Olorunfemi Akinlua6 min read
programming

Convert an array to a string in JavaScript (join, toString, JSON)

Convert array to string in JavaScript with join, toString, String(), toLocaleString, JSON.stringify, reduce, or loops—with example output and common pitfalls (objects, BigInt, null/undefined).

Olorunfemi Akinlua4 min read
programming

Cannot set headers after they are sent to the client (Express & Node.js)

Fix Error [ERR_HTTP_HEADERS_SENT] and cannot set headers after they are sent in Express/Node: double res.send, async races, middleware next(), error handlers, and res.headersSent—with tested client and log lines.

Steve Alila8 min read
programming

JavaScript appendChild() — add and move DOM nodes

Use Node.appendChild in JavaScript to add or move elements. Includes append vs appendChild, DocumentFragment batching, insertBefore, cloneNode, and jsdom-tested console output.

Olorunfemi Akinlua4 min read
programming

Convert SRT subtitles to plain text in JavaScript with regex

Convert srt to text or srt to txt in JavaScript: regex to remove index and timestamp lines, line-skip variant, block split for multi-line cues, Node readFileSync/writeFileSync with utf8—no npm install fs. Includes …

Olorunfemi Akinlua4 min read
programming

JavaScript date formatting with Intl.DateTimeFormat

Format dates in JavaScript with Intl.DateTimeFormat: locales, dateStyle and timeStyle, time zones, formatRange, formatToParts, and common TypeErrors. Includes tested sample output from Node.js (V8).

Olorunfemi Akinlua6 min read
programming

Parse a string to a boolean in JavaScript

Coerce strings with Boolean() and !!, or parse canonical values like 'true'/'false'. Learn the difference and avoid common mistakes.

Olorunfemi Akinlua2 min read
programming

Calling vs invoking functions in JavaScript: what actually happens to this

Call vs invoke and invoke vs call in JavaScript: both usually mean run a function. Clarify this binding, method calls vs free calls, Function.prototype.call naming, and library methods named invoke—with example console …

Olorunfemi Akinlua3 min read
programming

Detect ad blockers in JavaScript: bait DOM, heuristics, and what not to break

How to detect adblock in JavaScript: bait DOM patterns, getComputedStyle and offsetWidth checks, BlockAdBlock (blockadblock js) global guard, common API mistakes, limitations and false positives—with example branch logic …

Olorunfemi Akinlua5 min read
programming

Clear timeouts in JavaScript: clearTimeout and patterns that scale

Use clearTimeout (cleartimeout in search terms) to cancel one or many setTimeout timers. JavaScript has no built-in clear-all—track handles in a Set or array, including in Node.js. Includes Node-tested console output, …

Olorunfemi Akinlua5 min read
programming

Check if a key exists in a JavaScript object: 7 reliable patterns

Check if key exists in object JavaScript: Object.hasOwn, in, hasOwnProperty, Object.keys, getOwnPropertyNames, symbols, Reflect.ownKeys—with example console output and own vs inherited rules.

Deepak Prasad7 min read
programming

Check if an array is empty in JavaScript

Check if array is empty in JavaScript with length, Array.isArray, optional chaining, and loop patterns—plus pitfalls (array-like objects, sparse arrays). Includes Node-tested console output.

Steve Alila4 min read
programming

Golang goroutines: go routine examples, the go keyword, and waiting for work

Golang goroutine and golang goroutines: goroutine in golang with the go keyword, go goroutines and go routine spelling, minimal goroutine example, waiting with channels or sync.WaitGroup, and links to threads vs …

Antony Shikubu4 min read
programming

Go json.Unmarshal: Structs, Maps, Slices, null, RawMessage, and Errors

Deep guide to json.Unmarshal in Go: []byte and pointer rules, structs with tags, maps and float64 numbers, slices, nested JSON, any decoding, null, json.RawMessage, unknown fields vs Decoder.DisallowUnknownFields, …

Tuan Nguyen13 min read
programming

Golang Parse JSON: String, File, Struct, Map, and Decoder Examples

Learn how to parse JSON in Go using encoding/json: JSON strings, files, HTTP bodies, structs, maps, nested data, json.Unmarshal, json.Decoder, and common errors.

Tuan Nguyen9 min read
programming

Golang function vs method: declaration syntax, receivers, when to use which

Golang function vs method and go method vs function: golang function declaration syntax without a receiver, method golang syntax with value or pointer receiver, function vs method call style, golang methods vs functions …

Deepak Prasad3 min read
programming

Bash unshift: prepend to arrays, shift, and pop (with examples)

Bash unshift: prepend to an array or positional parameters, bash shift array / bash array shift, shift vs unshift, and bash pop argument / remove last element. No built-in unshift—use assignment or set --.

Deepak Prasad3 min read
programming

Bash while loop timeout: run until a time (sleep, date, GNU timeout)

Bash while loop timeout and while loop until a deadline: sleep in Linux/Bash, wall-clock end time with date or EPOCHSECONDS, counter + break, and GNU timeout around background jobs.

Deepak Prasad3 min read
programming

Linux convert tabs to spaces; spaces to tabs in shell scripts (Bash)

Linux convert tabs to spaces with expand; convert runs of spaces to tabs with unexpand; tab in bash with $'\t' and printf; unix shell scripts conversion for tab- vs space-delimited text and aligned columns.

Deepak Prasad3 min read