Home » Programming

Ruby vs Python – Which Programming Language to Learn in 2022?

Ruby vs Python

Learning to program but aren’t sure which language to choose? Python and Ruby are popular choices. This article will provide info to help you decide. What is Python? Python is a general-purpose programming language that can be used for everything from scripting to building full-blown web and desktop applications. It’s designed to be easy to read, easy to learn, and easy to write. It’s been in development since 1991, the current version being Python 3, which is under active development. Python bills itself as ‘batteries included’ – many libraries … Read more

Home » Programming

JavaScript: Compare Strings (Optionally Ignoring Case), With Examples

JavaScript Compare Strings

This quick tutorial will show you how to compare two or more strings in the JavaScript programming language – optionally ignoring case – with code examples. What are Strings? Strings are a series of characters. Each character has an ordered position in the string. A string can be of any length – from 0 (zero) characters to as many as you need until your computer runs out of memory. Strings are a type of variable. String type variables in JavaScript are variables that can hold a string … Read more

Home » Programming

Why Using the Right Variable Type is Important (Especially in Javascript)

Programming Variable Types

Variable types are a fundamental programming concept that often confuses beginners – especially those learning JavaScript. This article will show you the consequences of using the wrong variable types. What is a Variable Type? In computer programming, the type of a variable determines what values a variable can hold and what can be done with the variable. As an example, numeric variables can have mathematical operations performed on them, whereas string variables cannot (more on this later). Different programming languages support different types of variables, … Read more

Home » Programming

How to Convert an Object to an Array in JavaScript [Examples]

JavaScript Convert Object to Array

This article will show you the ways to convert an object to an array in JavaScript – quickly and easily. There are many ways to convert objects to arrays, but these (should) be the most straightforward methods. Converting Object to Array in JavaScript – Values Only If you only need the values from the object, the Object.values() method will extract them into an array: var myObject = { colour: ‘blue’, number: 43, name: ‘Fred’, enabled: true }; var values = Object.values(myObject); console.log(values); The above will return an array with … Read more

Home » Programming

Converting Object to an Array Recursively in JavaScript

JavaScript Recursive Object to Array

The Object.entries() method in JavaScript can be used to convert an object to an array – but it doesn’t work recursively. So here’s a function to accomplish that. I can’t think of a reason why you’d want to do this, but it came up while putting together an article on using Object.entries() – so here it is! Recursive Function for Converting Objects to Arrays I’ll let the comments do the talking as to what’s going on. The gist of it is that (for whatever reason) you want to convert an … Read more

Home » Programming

JavaScript: Remove the First/Last Character from a String [Examples]

How to Remove First/Last Characters from String in JavaScript

This tutorial will explain a few ways to remove the first or last character (or both!) from a string in the JavaScript programming language. This can be useful if you need to capitalize names or sentences or remove punctuation. Remove First/Last Character Using The substring() Method The JavaScript substring() method can be used to remove the first or last character from a string. You can find out more about the substring() and similar substr() methods here. The below code example shows how to remove the first, last, and both the first … Read more

Home » Programming

PHP_SELF – What It Is, and Why It’s Too Dangerous to Use [WARNING]

PHP_SELF

This article outlines the PHP_SELF attribute of the $_SERVER system information variable and why you should never, ever use it. What is _$SERVER? Check out our full article on $_SERVER here – but in short, it’s a variable containing an array with information about your PHP environment – including server and request details that are quite sensitive and shouldn’t be publicly accessible. What is $_SERVER[‘PHP_SELF’] ? $_SERVER[‘PHP_SELF’] contains the full path to the PHP script being executed, including any query parameters. This allows the party making the request to include arbitrary data. Displaying data … Read more

Categories PHP

Home » Programming

JavaScript substr() and substring() – What’s the Difference?

JavaScript substring/substr Difference

JavaScript has two similar-looking methods for extracting substrings from strings – substr() and substring(). This article explains the difference. These two functions perform almost the same function and have almost the same name, and at a glance, even seem to have the same syntax – but they’re different! Here is the syntax for each function – side by side so that you can see the difference. A Quick Reminder about Indexes An index is the integer number representing the position of an item in a series. Indexes start counting at 0 – so the … Read more

Home » Programming

What is the $_SERVER Superglobal Variable in PHP?

PHP _SERVER

This article will explain what the $_SERVER superglobal variable is in the PHP programming language. What is a ‘Superglobal’ Variable? A superglobal variable is a variable that is available to all scripts in all scopes in PHP. It is available from within any file, class, or function. What is the $_SERVER Superglobal Variable? The $_SERVER superglobal contains information about the server and execution environment PHP is running in/on. It contains information on the request made to the web server, file paths, and other information. It will provide little to no info … Read more

Categories PHP

Home » Programming

How to Update/Upgrade Python in Linux [Ubuntu/RedHat]

Update/Upgrade Python in Linux

This article will show you how to update Python to the latest version on your Linux Operating system. Python is updated yearly with new features and big upgrades – these are called major updates. In addition to this, monthly updates are released which fix small issues and improve security – these are called minor updates. Major updates change how Python works a bit and may break compatibility with some code as features are added or removed, whereas minor updates are solely there to fix problems without altering any functionality. Updating From Python 2 … Read more