Sep 9, 2021 JavaScript
How to check if a value is base32 encoded in JavaScript

In this Article we will go through how to check if a value is base32 encoded only using single line of code in JavaScript. This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => Arrow Function.

Let's define this short function:

const isBase32 = value => value.length % 8 === 0 && /^[A-Z2-7]+=*$/.test(value);

Sep 9, 2021 JavaScript
How to check if a value is base58 encoded in JavaScript

In this Article we will go through how to check if a value is base58 encoded only using single line of code in JavaScript. This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => Arrow Function.

Let's define this short function:

// It doesn't accept the I, O, l characters 
const isBase58 = value => /^[A-HJ-NP-Za-km-z1-9]*$/.test(value);

Sep 9, 2021 JavaScript
How to check if a value is base64 encoded in JavaScript

In this Article we will go through how to check if a value is base64 encoded only using single line of code in JavaScript. This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => Arrow Function.

Let's define this short function:

const isBase64 = value => /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{4})$/.test(value);

Sep 9, 2021 JavaScript
How to check if a value is nil in JavaScript

In this Article we will go through how to check if a value is nil only using single line of code in JavaScript. This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => Arrow Function.

Let's define this short function:

const isNil = (value) => value == null;

Sep 9, 2021 JavaScript
How to check if a year is leap year in JavaScript

In this Article we will go through how to check if a year is leap year only using single line of code in JavaScript. This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => Arrow Function.

Let's define this short function:

const isLeapYear = year => (((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0));

Sep 9, 2021 JavaScript
How to check if all array elements are equal to a given value in JavaScript

In this Article we will go through how to check if all array elements are equal to a given value only using single line of code in JavaScript. This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => Arrow Function.

Let's define this short function:

const isEqual = (arr, value) => arr.every(item => item === value);

Sep 9, 2021 JavaScript
How to check if a string is an octal number in JavaScript

In this Article we will go through how to check if a string is an octal number only using single line of code in JavaScript. This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => Arrow Function.

Let's define this short function:

const isOctal = str => /^(0o)?[0-7]+$/i.test(str);

Sep 9, 2021 JavaScript
How to check if a string is lower case in JavaScript

In this Article we will go through how to check if a string is lower case only using single line of code in JavaScript. This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => Arrow Function.

Let's define this short function:

const isLowerCase = str => str === str.toLowerCase();

Sep 9, 2021 JavaScript
How to check if a string is upper case in JavaScript

In this Article we will go through how to check if a string is upper case only using single line of code in JavaScript. This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => Arrow Function.

Let's define this short function:

const isUpperCase = str => str === str.toUpperCase();

Sep 9, 2021 JavaScript
How to check if a value is a business identifier code in JavaScript

In this Article we will go through how to check if a value is a business identifier code only using single line of code in JavaScript. This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => Arrow Function.

Let's define this short function:

const isBIC = value => /^[a-zA-Z]{6}[a-zA-Z0-9]{2}([a-zA-Z0-9]{3})?$/.test(value);