Home » Search results for 'javascript array'

JavaScript Escape Quotes / Escape Strings [Examples]

JavaScript Escape Quotes

This article will explain how to use escape characters to escape quotes in strings in the JavaScript programming language, with some examples. What is a String Variable in JavaScript? A string is a type of variable. It represents a series of zero or more characters. Other variable types are numeric, boolean, and array variables. A variable’s type defines what values it can hold and what can be done with it. For example, string variables can be split and joined to form new strings, and numeric variables can have mathematical operations … Read more

Home » Search results for 'javascript array'

How to Use the JavaScript ‘do while’ Loop, With Examples

JavaScript do while loops

This article will show you how a JavaScript do while loop is constructed, and what it us used for, with code examples. do while loops are one of the simplest kinds of loops, and appear in most programming languages. A do while loop runs a block of code repeatedly, until a condition is met. When the do while condition is met, the loop stops. It’s important to get familiar with using loops – and understanding how loops work – as they form the backbone of just about every game and application you might … Read more

Home » Search results for 'javascript array'

How to Reverse a String in JavaScript in One Line of Code [Example]

Javascript Reverse String

This quick tutorial will show you how to reverse a string in JavaScript. Strings are Array-Like Strings in JavaScript are considered array-like. A string is an ordered series of characters, so it can be considered as an array of characters. This makes it easy to convert a string to an array. We can then use any one of the methods available for reversing the array to reverse the string. This means you can use any of the methods we’ve previously outlined on reversing arrays on strings. … Read more

Home » Search results for 'javascript array'

How to Generate a Range (Numbers/Letters) in JavaScript

JavaScript Generate Range

This article will show you how to generate a range of numbers or letters in JavaScript, and provide some functions you can copy and paste into your own project. The Python, PHP, and many other popular programming languages provide a range() function, for generating a range of numbers or letters between two values. JavaScript does not have a built-in function for doing this, but it’s easy functionality to implement yourself. Here’s how to do it, and some pre-made functions you can just paste into your own project to use … Read more

Home » Search results for 'javascript array'

Exiting JavaScript Loops: ‘break’ & ‘continue’ [Examples]

Javascript Break Continue Statements

This article will explain the JavaScript break and continue statements and how they are used to exit and skip iterations in loops. JavaScript Loops In programming, a loop iterates through a series of values, performing an action on each value it encounters. Arrays can be looped through using the forEach method, and the for statement can be used to loop through a set of values generated by a JavaScript expression. You may encounter situations where you want to prematurely exit a loop, or skip processing certain values in the loop. This is what … Read more

Home » Search results for 'javascript array'

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 » Search results for 'javascript array'

Calculating the Absolute Value in JavaScript with Math.abs()

JavaScript Absolute Value abs()

This article will explain what absolute values are, how they are used, and how the JavaScript Math.abs() function can be used to calculate the absolute value of a number. What is the ‘Absolute Value’ of a Number? The absolute value of a number is that number’s value – without any regard to its sign. A numbers sign determines whether it is positive or negative – it’s the – symbol before a negative number. So, the absolute value of a number is never negative. Consider the absolute value of a number that numbers distance from 0. The absolute value of … Read more

Home » Search results for 'javascript array'

Capitalize the First Letter of Each Word in a String [JavaScript]

JavaScript Capitalize First Letter

This short article shows you how to capitalize the first letter in a string or all of the words in a string (title case) in the javascript programming language. Capitalizing the first letter in a string is useful if you’re capitalizing a single word or a whole sentence which you wish to display in a grammatically correct manner. Converting a string to title case – that’s where every word is capitalized in a string with multiple words – is useful for formatting text for use in an article … Read more

Home » Search results for 'javascript array'

How to Read a Local/Remote JSON File in JavaScript [Examples]

JavaScript Read JSON File

This article will show you how to read a JSON file into JavaScript as a JSON object – both local and remote files. What is JSON? JSON (JavaScript Object Notation) is a file format that stores objects, and arrays of objects, as human-readable text. It’s become the most popular method of storing and transmitting structured data on the internet. Thousands of APIs (used for mapping, communication, authentication, and many other purposes) use it as the format for submitting and receiving data. Desktop applications also use it to … Read more

Home » Search results for 'javascript array'

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