In this article I will discuss how to perform arithmetic and more advanced mathematical operations in JavaScript. First, though, I need to discuss how statements are formed and used in JavaScript.

In this article I will discuss how to perform arithmetic and more advanced mathematical operations in JavaScript. First, though, I need to discuss how statements are formed and used in JavaScript.

JavaScript programs are made up of statements. A statement can be anything from a single function call or command to even just a variable name. JavaScript evaluates statements and then executes them.

For example, when you create a variable, you write a statement:

`let number = 100;`

JavaScript recognizes this as a statement and evaluates it by following its grammar rules. In this case the rule is to assign the expression on the right-hand sign of the assignment operator to the variable on the left-hand side.

As I mentioned above, a statement can be just an expression, as in the following example:

```
js> 1;
1
```

You can do the same thing with a variable:

```
js> let name = "Brendan";
js> name
"Brendan"
```

Statements can be much more complicated than these examples, though, as you’ll learn as you get deeper into JavaScript. So far, you have seen examples of two types of statements — variable declaration and assignment statements and print statements.

Arithmetic is performed in JavaScript using the arithmetic operators. There are five arithmetic operators:

`+`

(Addition)`-`

(Subtraction)`*`

(Multiplication)`/`

(Division)`%`

(Modulo/Remainder)

These operators are binary operators, meaning there must be values on either side of the operator. The `+`

operator and the `-`

operator can also be used as unary operators, in which can they are used to distinguish the sign (positive or negative) of a number.

The JavaScript arithmetic operators also have an order of operations, or precedence, they follow when used in a statement. The order of operations is: 1) modulo; 2) multiplication and division; 3) addition and subtraction.

You can use parentheses to modify the order of operations. When an arithmetic expression is placed inside parentheses, that expression is evaluated before any other operations.

For example, take the expression:

`let n = 100 + 3 * 22;`

Does `n`

get the value 2266, 103 * 26, or does the variable get the value 166? Without parentheses the value of `n`

is 166 because the multiplication takes place before the addition due to the precedence of the multiplication operator over the addition operator.

learn-to-code learning-javascript javascript learn-to-program deep learning

Strings are the second most common data type used in JavaScript, and in many cases, since JavaScript is so widely used for web applications, it is the prominent data type.

In this article I’m going to cover the different forms of the for loop that are available in JavaScript. There is the general for loop, the for..in loop, and the for..of loop. I will describe how each loop works and when is the right time to use each loop type. I am leaving out the Array.forEach loop as it is specialized for arrays and requires some knowledge of functions I haven’t covered yet.

Although we still talk about programming as a standalone career, the dominance of technology in our lives makes it clear that coding is much more than a career path. In my opinion, computer science is more than a college major or a high-paid job; it’s a skill, essential for thriving in a modern-day economy. Whether you work in healthcare, marketing, business, or other fields, you will see more coding and have to deal with a growing number of technologies throughout your entire life.

JavaScript has a set of built-in methods you can use with your user-defined objects. In this article I’m going to discuss several of these methods and how you can use them in your JavaScript programs.

JavaScript objects provide the reader with some special features that make object-based programmer more effective and more efficient. In this article I’m going to describe three of these features — the this keyword, getters, and setters. The this Keyword If there was ever a more confusing keyword in computer programming than thethiskeyword, I don’t know what it is.