Author: adminuser
-
JavaScript Tutorial Series – Arrays
In JavaScript, arrays store a list of items. An item may be a primitive such as a string or number. An item may also be an object or another array. Indexing starts at 0. Arrays are objects. To determine if a variable is an array, use Object.prototype.toString.call(theArray) === ‘[object Array]’ or the newer way of…
-
JavaScript Tutorial Series – Variables
In JavaScript, variable names must start with a letter or underscore, are case sensitive and multiple words should be camel cased, example: aVariableName. Variable names may only contain letters, numbers and underscores. JavaScript determines what type a variable is. There are primitive and complex types. Valid primitive types include string, number, boolean, null, symbol and…
-
JavaScript Tutorial Series – Style Guide
A best practice in programming is to adhere to a consistent style guide. It allows for more readable code and easier maintenance. All code looks uniform even when multiple people contribute to it. JavaScript doesn’t have one set standard style guide. There are a couple of different style guide options though. These are provided by…
-
JavaScript Tutorial Series – Comments
Comments are used to make notes in source code about what a piece of code does or to not include executable lines of code when the application is run. Comments are not rendered on the page when the containing JavaScript file is loaded. Comments are created in JavaScript by adding 2 forward slashes, //, in…
-
JavaScript Tutorial Series – IDE
JavaScript source files end in .js. JavaScript source files can be written in a simple text editor. IDE’s will offer a better experience though as they have features such as code completion, a debugger, error highlighting and source code formatting. I use NetBeans or Visual Studio Code. Other options include Eclipse, Atom, Komodo and Brackets.…
-
JavaScript Tutorial Series – Set Up
JavaScript runs in a web browser, so all that is needed to get started is having a web browser, such as Google Chrome, Firefox or Internet Explorer, etc. installed on your computer. That’s it. Super simple. Implementation: The goal of this JavaScript Tutorial series is to teach JavaScript to someone with programming knowledge. This tutorial…
-
JavaScript How To Convert Recursive Function With Callbacks to Use Promises
I updated one of my websites to use JavaScript promises instead of callbacks. It was pretty straightforward, but got a little tricky for a recursive function. Below is how to do the conversion update: Recursive callback function: function doSomething(value) { function callback(result) { console.log(‘Done ‘ + result); …
-
JavaScript How to Convert Callback to Promise
I finally finished upgrading my travel website to use Promises instead of callbacks. It was fairly straightforward. This is an example of the callback: function hasacallback(param1, callbackFunction) { var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { callbackFunction(this.responseText); …
-
Python Tutorial Series – Packages
Python modules can be organized into packages. A package is a namespace which contains a set of modules. Packages are useful for organizing modules, especially when an application is large and contains a lot of modules. To create a package, create a directory and add python files to it. The directory must contain an __init__.py…
-
Python Tutorial Series – Classes
In object oriented programming, classes are used as a blueprint to define objects in an application. Classes are a way to organize code, provide the ability to easily extend functionality and allow for reuse. In Python, a class is defined as follows: class BaseClass: # constructor def __init__(self, param1): self.param1 =…