JavaScript operators

What are operators

javascript

The operator is usually a symbol that is used when we want to perform some standard, frequently used operation, such as assignment of values, comparison of values, arithmetic operations…
Operators can be understood as special functions which, unlike “ordinary functions”, are written in a “non-standard way”. Operators use the so-called “infix” notation (the function name is placed between two parameters). The standard operator shown with “infix” notation looks like this:
... operator...
The following example shows that there is an essential similarity between the operator and the function:

The most common are binary operators (operators that take two values as input), although there are also unary operators that perform certain operations on only one value:

Read more

Type conversion in JavaScript

Introduction

javascript_konverzija

JavaScript is a loosely typed language, which means that it does not require you to clearly declare the data type when declaring a variable. In JavaScript, the type of a variable is implicitly declared by associating a specific value with the given variable.
Javascript is also a language of dynamic types because it is possible to change the type during the execution of the program. The result of the conversion is always some primitive value, ie. there is no conversion that results in some complex value (such as an object or function). Unlike JavaScript, TypeScript (a JavaScript superset language) is a “strongly typed” language that requires a type to be defined when declaring a variable and does not allow implicit type changes.

Read more

Front-End Tools (Overview)

Package manager

Introduction

frontend

Today’s web development is based on a set of different technologies that are used simultaneously on one project, such as: Typescript (language), Sass (CSS extension), JSCS (code style linter and formater), JSHint or TSLint (a tool for detecting errors and potential problems), BrowserSync (a tool for synchronizing changes in the code and in the browser – Live reload)… One project requires the installation of each of the mentioned programs but also of all programs (dependencies) on which they depend and which precede their installation.
Package manager eliminates the need to manually install software with all necessary supporting software (dependencies) and to update all those components. Package manager is a set of tools responsible for automating the process of installing, configuring and removing programs. Package managers work with packages ie. with software or data contained in archive files. Packages contain meta-data that describe the given software such as the name of the software, the version and a list of all dependencies (other software necessary for the given software to work). The most famous package managers are:

  • npm
  • bower
  • JSPM (JavaScript Package Manager)
  • Yarn

Read more

The meaning of the “this” operator in JavaScript

Introduction

js this

Developers use one of these two mechanisms:

  • lexical range of visibility
  • “this mechanism”

The mechanism using the “this” keyword provides an elegant way to implicitly “pass” a reference to a particular object, resulting in a cleaner design and easier code reuse. Developers who avoid using this mechanism mostly do so because they don’t understand the principles of how that mechanism works.

“This” is not a variable but a special programming language word (operator) and represents a link that points to some reference (object). It is activated, i.e. gains meaning only at the moment when the function that contains it is called (invoke).

It does not depend on where the function is declared, but solely on where and how the function is called!

Rules for determining the meaning of “this”

The whole process of determining the meaning is based on recognizing “who” and how it calls the function containing “this”. The sequence of actions is as follows:

  1. First it is checked whether the constructor function is called with operator new(). If it is called in this way, then the value “this” is explained under the point a) Calling the function with the operator “new” but if it is not called in this way, then it is done…
  2. … control whether the function is called with the help of call(), apply() (or bind) methods. If it is called in this way, then the value of “this” is explained under point b) Calling with call(), apply() or bind(), but if it is not called in this way, then it is done …
  3. …check if the function is called as a method of the object. If it is called in this way, then the value “this” is explained under the point c) Calling the method of the object, but if it is not called in this way, then it is…
  4. default linking, which is explained under d) Default linking

If by any chance several different rules are used, priority is applied according to the order from the previously described procedure.

Read more

Events in JavaScript

Introduction

Events are phenomena, which are most often the result of something the user does (mouse click, keyboard click, drag and drop…), although they can also be caused by the system, browser… Registering an event on an HTML element implies binding an event listener (eng. event listener) to the HTML element and defining the consequence of that event. The Event listener, after the event has been executed, calls the event handler (eng. event handler) to action. Event handler is a callback function that is activated as a result of some event.

Read more

Overview of built-in JavaScript objects

Introduction

js this

Within JavaScript itself, there are built-in objects with their own properties and methods, intended to make programming easier.

  • Array
  • Math
  • Given
  • Function

In addition to the listed objects, there are also objects whose names are the same as the names of simple primitives (only with a capital letter):

  • String
  • Number

These objects are “equipped” with the methods needed to work with the corresponding data type and are intended to make working with primitive types easier. When the need arises for an operation on such a primitive type, the compiler automatically “wraps” the primitive type in its “counterpart” object, after which all methods of the built-in object are available.

In this article, I wanted to clearly gather in one place all methods and properties of objects embedded in javascript.

Read more

Installation of web development tools

Introduction

alati

This article serves as a reminder to a web developer to install all the necessary tools to work on a new or reinstalled computer. The installation of the tools that I personally use as well as some of their basic settings are described in detail. Web development covers a large number of different technologies and programming languages, therefore the list of required applications is also large.

Read more