Home » Search results for 'javascript array'

Implementing a Queue Data Structure in JavaScript [Examples]

JavaScript Queue

A queue is a commonly used data structure in programming. Here’s how to implement and use a queue in JavaScript. JavaScript doesn’t include a data structure specifically called a queue – but that doesn’t mean the functionality isn’t there. JavaScript arrays can be used in the same way – it’s just the terminology that’s a bit different. Rather than duplicating array functionality for queues, queue functionality exists in the array functions of JavaScript. What is a Queue Data Structure? A queue is a sequence of items in a specific order. Items can be enqueued (added … Read more

Home » Search results for 'javascript array'

PHP: Process Each Item In An Array with array_map() [Examples]

PHP array_map

This article will show you how to process a PHP array using array_map() to run a function on each item in the array. Why use array_map()? Arrays store a sequence of values in a single variable. If you’re storing those values, you probably want to do something with them at some point. Say, for example, you had an array of numbers, and you wanted to calculate the square of each number to be stored in a new array. You could create an empty array, loop through the original array calculating … Read more

Categories PHP

Home » Search results for 'javascript array'

JavaScript Libraries We’re Using to Build Apps in 2022

Javascript Libraries

JavaScript libraries take the legwork out of building complex applications. Here are some of the most useful libraries to use in 2021/2022. Once you’ve graduated from ‘Hello World!‘ and understand how JavaScript works, you’ll probably want to dive into building something more useful – a website, or a service, or a mobile app. These all have many moving parts – Authentication so users can log in, database support for storing data, file uploads so users can store their cat pictures in the database – all of these … Read more

Home » Search results for 'javascript array'

How to Create and Use Enums in JavaScript (Not TypeScript)

JavaScript Enum

This article will show you how to create and consume Enums in JavaScript. Unfortunately, javaScript does not include native support for Enums, but you can add comparable functionality yourself. Note that TypeScript, a language that builds on JavaScript, does include support for Enums natively. So we’re only looking at plain JavaScript here – not TypeScript. What is an Enum? An Enum (Enumerated Type) is a data structure containing multiple values. Each value is assigned to an identifier – and can be accessed by that identifier. Enums contain pre-defined constants … Read more

Home » Search results for 'javascript array'

JavaScript String split() Method, With Examples

JavaScript Split Method

Want to split a string up into several smaller strings using JavaScript? This is the article for you. The JavaScript string.split() method will split up a string and return an array of strings. The string will be split at the position noted by a specified character. Here’s how to use it. JavaScript string.split() Syntax A method is a function or procedure available to run from an object or variable which will be run using the value from that variable. The split() method is available on any string typed variable. Here’s the … Read more

Home » Search results for 'javascript array'

Beginners Guide: Create and Use JavaScript ES6 Modules

JavaScript Modules

This short tutorial aims to get you started creating and using JavaScript modules and provides some simple examples. What is ES6? JavaScript’s official name is actually ECMAScript, and version 6 introduced module functionality to create and consume modules, so you might see JavaScript Modules referred to as ES6 or ES2015 Modules. What is a JavaScript Module? As you get more adventurous with your JavaScript programming projects and your code becomes more complex, it might start to become harder to manage. One way of mitigating this is splitting … Read more

Home » Search results for 'javascript array'

Multidimensional Arrays in PHP – How To Use, With Examples

PHP Multidimensional Arrays

This article will show you how to use multidimensional arrays in the PHP programming language, explaining what they are and how to use them. What is an Array? An array is a type of PHP variable that can hold multiple values. It’s a list of values you can loop through and perform operations on each individual value. For example, you might want to perform an action on a list of files. By storing that list as an array, you can loop through the file names … Read more

Categories PHP

Home » Search results for 'javascript array'

JavaScript Callback Functions How-To, With Examples

JavaScript Callbacks

This article will explain callback functions in JavaScript – what they are, why they’re used, and how to use them. What is a Callback in the JavaScript Programming Language? A callback function is a function that is passed as a parameter to another function to be executed from within the second function. What are Callbacks Useful For? Callback functions are usually used to execute a function when another has been completed. This allows for easy code- reuse. A single function that accepts a callback can be … Read more

Home » Search results for 'javascript array'

How to Refresh the Page in JavaScript using location.reload(), With Examples

JavaScript Refresh Page

Here’s a short guide to refreshing a webpage with JavaScript, with examples. There are over 500 ways to trigger a page reload using JavaScript. All but one are unofficial or are the side effect of another behavior. Here’s how to do it properly. Using location.reload() Simply call: location.reload() …anywhere in your code to trigger a page reload. It’s that easy. What about window.location.reload() ? You may see some use: window.location.reload() This is exactly the same as using location.reload() – the window object in JavaScript is the global context, so there’s usually no … Read more

Home » Search results for 'javascript array'

Concatenating (Joining) Strings in JavaScript [3 Methods]

javascript string concatenation

Being able to concatenate (join) two or more strings together is pretty useful – you may be combining user input for storage in a single database column or doing the reverse – combining data from multiple database columns into a single string for display or output. There are several ways to concatenate strings in Javascript, and we’ll cover these methods below, along with some useful examples. The string.concat() Method The string.concat() method will join any number of strings to a given initial string. Syntax string.concat(string1, string2, string3…) Note that: string is … Read more