-
JavaScript JSON methods, toJSON
The JavaScript Object Notation (JSON) is a notable format for representing objects and values. Initially, this format was created for JavaScript, but several languages also include libraries for handling it. Hence, it is easier to use JSON for data exchange in case the client uses JavaScript, and the server is written on PHP, Ruby, Java, and more. In general,…
-
JavaScript Date and Time
In JavaScript, there is a built-in object Date for handling all the date and time related operations. For instance, you can use it for displaying the current date and time, creating a calendar, build a timer, and much more. How to Create a Date Object To learn how to create a new Date object, follow the steps…
-
JavaScript Destructuring Assignment
Object and Array are the two frequently used data structures of JavaScript. With the help of the objects, you can create an entity storing data items by key. With the help of the arrays, you can assemble data items into an ordered collection. In case of passing those to a function, it might need an object and array…
-
JavaScript Object.keys, Values, Entries
In this chapter, we are going to cover Object.keys, values, and entries. We have already spoken about methods such as map.keys(), map.values(), map.entries(). These methods are universal and are used for data structures. Every time after creating a data structure, they should also be implemented. They are mainly used for Map, Set, and Array. Similar methods are supported by plain…
-
JavaScript WeakMap and WeakSet
In chapter Garbage Collection, it was stated that the JavaScript engine can store a value in memory once it is reachable. Here is an example: As a rule, properties or elements of data structures such as an object or an array are reachable and kept in memory once that data structure is in memory. For example, after putting an object into an…
-
JavaScript Map and Set
While working with JavaScript, developers waste a lot of time on choosing the right data structure. Objects and Arrays are the primary data structures used to store collections of data. Objects are used for storing key/value pairs, and arrays- for indexed lists. To make developers’ life easier, ECMAScript 2015 represented two new kinds of…
-
JavaScript Iterables
The protocol of iterations enables JavaScript objects to define and customize their iteration behavior like what values are looped over in for…of. Arrays are considered iterable. But, there are also other iterables (for instance, strings). Describing Symbol.iterator Let’s try to create an iterable. For instance, there is an object, which is not an array but can be suitable for for…of.…
-
JavaScript Array methods
In JavaScript, there exist a wide range of array methods. To give you more detailed and comprehensive information, we are going to split them into groups. Add/Remove Methods In chapter Arrays, we have already spoken about this group of methods. Among them are: In this chapter, we will speak about several other methods. Splice The first…
-
JavaScript Arrays
In this chapter, we will explore JavaScript arrays. In JavaScript, you can use arrays for storing multiple values in a single variable. We can describe an array as a unique variable capable of holding more than one value simultaneously. There exist two syntaxes for generating an empty array: The second syntax is used most of…
-
JavaScript Strings
In JavaScript, the strings are used for storing and manipulating text. No separate type exists for a single character. The strings internal format is always UTF-16. A string represents zero or more characters that are written inside quotes. About Quotes We can distinguish single quotes, double quotes, and backticks: Double and single quotes are the same. Anyway, backticks are different.…