Currently browsing JavaScript

Tuesday, May 10, 2022

Understanding JavaScript Currying

I recently fully understood the concept of utilizing Currying in JavaScript. The core concept can be grasped from these references: Wikipedia entry on…

Tuesday, May 10, 2022

How and Why to Avoid ‘for’ Loops

Never again use for() for looping. Using for() can be dangerous, especially if you use a library which adds attributes…

Tuesday, May 10, 2022

JavaScript Random String Generator

I needed a random string for various purposes. For example, to provide a unique ID to HTML elements via JavaScript.…

Tuesday, May 10, 2022

John Resig’s Inheritance

John Resig, the creator of jQuery, has created this JavaScript inheritance code. I am still using it now to simplify several…

Tuesday, May 10, 2022

Encapsulation: Private Attribute

In JavaScript OOP there are attributes called private attributes. Knowing if an attribute is private or public, an API user…

Tuesday, May 10, 2022

Encapsulation: Private and Public Methods

When it comes to developing APIs, self documenting code is very important, in order to simplify users’ effort in filtering…

Tuesday, May 10, 2022

Giving Object Context to Function Calls

JavaScript has a dynamic object named this. By default, this equals to the global object container, so if we have…

Tuesday, May 10, 2022

Self Documenting Flexible Parameters

Changing the number of JavaScript function parameters can be unproductive because of the need to update other code calling that…

Tuesday, May 10, 2022

Use ‘this’ Keyword with setTimeout()

setTimeout() is a great help to many JavaScript developers. For example, you may wish to add a delay to allow…

Tuesday, May 10, 2022

Load a JavaScript File on the Fly

Similar to my previous article on how to add/inject a CSS stylesheet using Vanilla JavaScript, this is how you load…

Friday, June 3, 2022

Generate HTML List From JavaScript Array

Generate an HTML list based on the contents of a JavaScript array. By modifying the makeList() function to accept parameters…

Tuesday, May 10, 2022

Same-Origin AJAX Request Using Vanilla JavaScript

This JavaScript function will send an AJAX request - GET or POST - with no third-party dependencies. I find it…