Javascript 101 — Arithmetic Operators, Code Editors, Functions, Objects, and Arrays — 02

Melih Turhanlar
3 min readDec 27, 2021

Before reading this article you can look Javascript history, console, and data types.

Like all programming languages, javascript also has operator precedence this link gives good tables, we can look at it.

and also we can remember it as B O DM AS:

- B = Brackets
- O = pOwers() and Functions
- DM = Division and Multiplication
- AS = Addition and Subtraction

Assignment Operators

Here we can see some examples of arithmetic usage of Javascript.

When we try to add string — string to a number, boolean to string javascript use polymorphism, so the type of variables changes.

Code Editors & Debugging

Development tools are can be deleted during refreshing websites etc. So, we can be needed in an IDE. Brackets is an open-source Javascript IDE.

# sudo snap install brackets — classic

In Linux,`` you can easily install IDE with the command above.

After configuring your index.html file and example.js file
you can easily work with your web browser console but here don't forget to clean filter results because you can’t see your `console. logs`.

``` html
<!DOCTYPE html>
<html>
<head>
<meta charset=”utf-8">
<title>Javascript 101</title>
</head>
<body>
<h1>Javascript 101</h1>
<script src=”example.js”></script>
</body>
</html>
```
the HTML file which you can debug your js files.

``` javascript
console.log(“Hello Javascript 101”);
```

You can copy these examples in your folder and as it is stated in the previous part and run javascript codes.

Functions

Basically, functions are defined instructions that have input and output. Inputs are defined as parameters and take data into function and work with them. After some process in function, functions can return output.

For example, let’s write a substitution function.

``` javascript
function subThem(first, second)
{
var result = first + second;

return result;
}
```

When we refreshed the index.html we can see the output of our javascript function.

Objects and Arrays

Let’s give an example of what is an object!. The object is everywhere in our life. For example Cars, Televisions, coffeemakers, refrigerators, washing machines etc. All of them have some properties and functions in them.

We call functions in objects as methods. Methods = Function in Objects.

Here is an example of javascript object.

``` javascript
var car = {

color : “blue”;
speed : 200;
drive : function (){ return “car is on road”;}
}
```

Arrays

These are lists with index numbers. In javascript it is implemented with ``[]``.

So when we want to define an array

``` javascript
var bigarray = [
“Orange”,
“Sugar”,
“Salt”,
“Apple”
]
```

Here, we can see easily our object and array.

--

--