Home » Search results for 'javascript object'

How to Write to a File Using JavaScript, With Examples

Write to File in JavaScript

This article will show you how to write to files from JavaScript – both from the web browser and Node.js environments. With examples on how to write, append, update, delete and rename files. JavaScript code is usually run from one of two environments – within a web browser when viewing a web page or in a Node.js environment which allows JavaScript to be executed outside of a web browser – commonly used for building back-end services and web apps. Write to a File From the Browser … Read more

Home » Search results for 'javascript object'

Converting to Float Numbers with the parseFloat() JavaScript Function, With Examples

JavaScript ParseFloat()

This article will explain floating-point numbers and how to convert values to floating-point numbers using parseFloat() in JavaScript. Looking to convert to an integer value instead – use parseInt()! What is a Floating Point Number? In programming, a floating-point number (commonly just called a float) is a number with any number of characters before or after a decimal point. A floating-point number might look something like this: 14.392 A floating-point number or float is also a type of variable. A variable’s type determines what kind of values it can store and what can be done with the variable … Read more

Home » Search results for 'javascript object'

How to Convert String to Date in JavaScript, With Examples

JavaScript String to Date

Here are some easy-to-understand methods for converting strings to date objects in the JavaScript Programming language. Looking to compare dates in JavaScript? Find out how here. The Hard Way – Using Vanilla JavaScript JavaScript contains built-in functions for parsing a date from a string – but it’s severely limited. So here it is in action: var myString = ’01 Jan 1970 00:00:00 GMT’; var myDate = new Date(Date.parse(myString)); What’s happening here? A string is defined containing a date. A new Date object is then defined using the … Read more

Home » Search results for 'javascript object'

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 object'

The Best Way to Declare an Array in JavaScript

JavaScript Declare Array

There are several ways to declare an array in JavaScript. This article will show you which is the best. What is an Array? An array is a type of variable that holds an ordered list of values. Each value has a position in the array, called the index. The index can be used to access each value in the array. Indexes are integer values, which start counting from 0 (zero) for the first item in the array. The Literal Constructor – Declaring an Array using Square Brackets (The Best … Read more

Home » Search results for 'javascript object'

How to Add one or More Items to an Array In JavaScript with push()

JavaScript Add Item to Array with push()

This tutorial will show you how to add items to a JavaScript array with the push() method – with code examples. You don’t want to have to re-declare an array every time you want to change the values in it – so let’s look at how to add items to existing arrays using the push() method. About JavaScript Arrays and Declaring Arrays I’ve covered the best way to declare Arrays in JavaScript in our article here. JavaScript Array push() Method Syntax A method is a function or procedure attached to an object. Calling that object’s … Read more

Home » Search results for 'javascript object'

How to Reverse an Array In JavaScript

JavaScript Reverse Array

This short article will show you how to reverse an array in the JavaScript programming language. What is an Array? An array is a type of variable that holds an ordered list of values. Each value has a position in the array, called the index – and can be accessed by using that index. As an array is ordered, the position matters. Values within arrays will be processed by loops and other data structures in order – so being able to reverse that order is beneficial. Reversing an … Read more

Home » Search results for 'javascript object'

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 object'

Check if a JavaScript Variable is an Array with isArray() [Examples]

Javascript Array.isArray()

Here’s a short article that explains arrays and how to check if a JavaScript variable is an array using the Array.isArray() method. Want to check out whether an array contains a value? Find out how here. What is An Array? An array is a type of JavaScript variable that can hold other variables, or references to other variables, in a list at a certain position. Declaring an Array in JavaScript An array is declared in JavaScript the same way as any other variable – by assigning the value … Read more

Home » Search results for 'javascript object'

Checking for null values in JavaScript, With Examples

Javascript Null Check

What is null in JavaScript, and how can you check if a value is equal to null? Read on to find out. What is Null? Null is a term with a special meaning in computing and computer programming. Null is not 0 (zero). Null means that something has no value. Zero is a value (a number). An empty string has a value (though sometimes called a null string, they aren’t null). A variable with a value of null is considered to be empty. It is not undefined – it has been defined … Read more