Deep Tech Point
first stop in your tech adventure
Home / Javascript
February 22, 2021 | Javascript

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:

  • the spread syntax,
  • the object rest syntax,
  • object.assign() method,
  • and the JSON.stringify() and JSON.parse() methods.

So, take a look at each and see when it’s best to use a specific method.

February 21, 2021 | Javascript

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?

February 19, 2021 | Javascript

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;
}

February 17, 2021 | Javascript

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.

February 15, 2021 | Javascript

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.

February 14, 2021 | Javascript

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.

February 12, 2021 | Javascript

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.

February 11, 2021 | Javascript

What is null in Javascript?

In JavaScript the value null represents the intentional absence of any object value. The value null is one of JavaScript’s primitive values and is treated as falsy for boolean operations. We could compare a value null to a similar primitive value – undefined. Undefined is an unintentional absence of any object value, and this “unintentional” is the thing that differentiates null from the undefined.

January 31, 2021 | Javascript

What if you are developing an application that requires a client to upload a file or an image and information about the image via RESTful API and you want the client to send data as JSON? The easy answer would be to perform two posts to REST API.
But is that even possible in a single request?

January 27, 2021 | Javascript

Recently I’ve been running into problems trying to save JSON in the MySQL database. Even though MySQL supports JSON type for a while now, there are still plenty of gotchas while you work with it. The situation is pretty critical with special characters. This time we are going to be short and on the topic of invalid JSON characters.