-
JavaScript setTimeout and setInterval
JavaScript allows you not only to invoke the function right now but also a particular time later. The latter is known as a “scheduling call.” Two main methods can be highlighted for it: These methods are generally supported in all browsers, as well as Node.js. setTimeout For setTimeout this syntax is used: It has the following parameters:…
-
JavaScript The “new function” Syntax
There is another way of creating a function. It’s not used often, but in times, there is no alternative. Here is the syntax that can be used for function-creating: It is created with the following arguments: arg1…argN and the functionBody. It is demonstrated in the following example: In another example, you can see a function without arguments but…
-
JavaScript Function object, NFE
In the previous chapters, we have already learned that functions in JavaScript are values. Also, each JavaScript value has a type. Now, it’s time to learn the types of functions. Functions are objects in JavaScript. It is possible not only to call objects, but to deal with them as objects (add or remove properties, pass…
-
JavaScript Global Object
An object that constantly exists in the global scope is called a global object. In JavaScript, the global object supplies variables and functions that can be available everywhere. It is called a window in the browser, global - in Node.js, and can have other names in different environments. Lately, a standardized name globalThis was added for the…
-
JavaScript The Old “var”
In this chapter, we represent the old scripts. It’s not about writing new codes. Let’s start at the very beginning. As you have already learned, there are three main ways for variable declaration: The var originates from ancient times and is different from the other 2. In general, it is not used in modern scripts. var may seem similar to let,…
-
JavaScript Variable scope
JavaScript is one of the most function-oriented programming languages. In JavaScript, it is possible to create a function, dynamically passed as an argument to another function, and called from a different place of code after. Variable scope is one of the first things to learn in JavaScript.The location of the variable declaration controls the scope of…
-
JavaScript Rest Parameters and Spread Syntax
JavaScript has a range of helpful features allowing developers to work with arrays and function parameters much effortlessly. In this chapter, the rest parameters and spread syntax are covered. Rest Parameters … The rest parameter gives you a robust way to work with an indefinite quantity of parameters. For better understanding what rest parameter is,…
-
JavaScript Recursion and Stack
Recursion is the process in the framework of which a function calls itself, either directly or indirectly. It is especially handy in situations when there is a necessity to split a single task into several simple ones. Above all, with the help of recursion, you can write quite elegant codes. To understand better what recursion is,…
-
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…
