Should I use single (‘) or double (“) quotes when working in JavaScript? That’s the question now.
'abc' === "abc" // true
Should I use single (‘) or double (“) quotes when working in JavaScript? That’s the question now.
'abc' === "abc" // true
In this article, you’re going to learn when to use const in JavaScript, what is a constant (const), and how it’s different from an “ordinary” variable (let).
…
Semicolons are optional in JavaScript, but sometimes they’re not. Wait, what? Are they optional or not?
…
In this article, we are going to present how to clone an object in Javascript. There are actually at least four ways to copy an object and they differ from each other in a few ways. You can use:
So, take a look at each and see when it’s best to use a specific method.
…
In this article, we are going to investigate what are the differences (and similarities) between JavaScript arrays and objects, and how do you know when to use objects vs arrays?
…
Maybe you have an issue with a server, which is sometimes returning either a JSON string with some useful data, and at other times server returns an error message string, which is produced by the PHP function mysql_error(). A simple solution to this problem would be to test whether this data is a JSON string or an error message.
A straightforward answer to a question on how to test if a string is JSON or not would be to use JSON.parse function isJson(str), like so:
function isJson(str) {
try {
JSON.parse(str);
} catch (e) {
return false;
}
return true;
}
Nullish coalescing operator is a logical javascript operator that was introduced in JavaScript with the launch of ES2020 aka ES11and is symbolized with double question marks (??).
The nullish coalescing operator is a logical operator that accepts two operands – one on its left-hand side and one on its right-hand side and the syntax looks like this:
LeftHandSideOperand ?? RightHandSideOperand
Let’s see where we can use it.
…
In Javascript both var and let are used to declare a variable. However, there are a few differences between javascript var vs let, so let’s take a look at them.
…
Javascript language is de-facto standard for making client-side web applications that consume different kinds of APIs. It can even be used for mobile applications thanks to wrapper frameworks such as Apache Cordova, React Native, or NativeScript. You can even use it with gaming frameworks like Cocos 2D, Unity, or many others. Almost all games published in recent few years, especially for mobile phones can also be classified as client-side applications that interact with server-side sending and receiving data such as score, in-game positions, moves, and many others to the server through an API.
But let’s take a look at a simple example of Javascript client application that consumes an API using a built-in fetch function.
In Javascript we have a couple of options for checking equality, so let’s take a look at them – what are similarities, and what are the differences.
…