JavaScript
Published: 2020-11-21 21:51:37

#**_Introduction_**

JavaScript is a less-than-complex language that lets you implement innovative features onto your webpages. Any time you see dynamic webpages, or anything interactive on a webpage, there is a very high possibility that there is JavaScript behind it. JavaScript can work to make 2D/3D designs, clocks, jukeboxes, and so much more!

#**JavaScript Elements**

###**_JavaScript Types_**

#####**_Number_**

> *A Number is the most straightforward type of JavaScript that can be written, it is simply just numbers that can be types into the code.*
```JS
let x = 23;
console.log(x);
//Output = 23
```

#####**_String_**

> *A String is JavaScript is seen as alphabetical characters such as "John Doe" or "The Dog". It can be seen as text, but it must between a set of quotation marks or apostraphes.*
```JS
let x = "Tulips";
console.log(x);
//Output = Tulips
```

#####**_Boolean_**

> *A Boolean is a type of JavaScript Value that yields as only true and false. For example `"Dog" == "Cat"`, this returns as `False`.*
```JS
let x = 37;
let y = 42;
let z = Boolean(x == y);
console.log(z);
//Output = "False"
```

#####**_Object_**

> *An Object in JavaScript is a variable that contains multiple elements, such as weight, name, color, and other descriptive modifers.*
```JS
let mrGreen = {
        firstName: "Jacob",
        lastName: "Green",
        occupation: "Entrepreneur",
        age: 45,
        description: "He has a lot of connections",
        color: "green"
    };
```

#####**Array**

> *An Array in JavaScript is a variable That acts like a list, and can contain a series of other elements such as strings, objects, or other JavaScript compnents.*
```JS
let list = ["Apple", "Orange", "Banana"];
console.log(list[2])
//Output = "Banana"
```

###**_JavaScript Comparisons_**

Comparisons are typically used with Boolean operators, to modify what the Boolean function does.

#####**Not Equal To (!==)**

> *Not Equal To is one of the two simplest statements in all of Boolean operations. It is also straightforward in meaning, meaning something is not equal to another thing.*
```JS
let x = Boolean(4 !== 3);
console.log(x);
//Output = True
```

#####**_Equal To (===)_**

> *Equal To is the other one of the two simplest statements in all of Boolean operations. It is also straightforward in meaning, meaning something is equal to another thing.*
```JS
let x = Boolean(23 == 23);
console.log(x);
//Output = True
```

#####**_Greater Than or Equal To (>=)_**

> *Greater Than or Equal To is a Boolean operator that judges not only whether one number is equal to another, but also whether it is greater than it. It is also straightforward in meaning, meaning something is greater than or equal to another thing.*
```JS
let x = Boolean(37 >= 23);
let y = Boolean(23 >= 23);
let z = Boolean(18 >= 23);
console.log(x + ", " + y + ", " + z);
//Output = True, True, False
```

#####**_Less Than or Equal To (<=)_**

> *Less Than or Equal To is a Boolean operator that judges not only whether one number is equal to another, but also whether it is less than it. It is also straightforward in meaning, meaning something is less than or equal to another thing.*
```JS
let x = Boolean(37 <= 23);
let y = Boolean(23 <= 23);
let z = Boolean(18 <= 23);
console.log(x + ", " + y + ", " + z);
//Output = False, True, True
```

#####**_Greater Than (>)_**

> *Greater Than  is a Boolean operator that judges only whether one number greater than another.*
```JS
let x = Boolean(37 > 23);
let y = Boolean(23 > 23);
let z = Boolean(18 > 23);
console.log(x + ", " + y + ", " + z);
//Output = True, False, False
```

#####**_Less Than (<)_**

> *Less Than  is a Boolean operator that judges only whether one number less than another.*
```JS
let x = Boolean(37 < 23);
let y = Boolean(23 < 23);
let z = Boolean(18 < 23);
console.log(x + ", " + y + ", " + z);
//Output = False, False, True
```

###**_JavaScript Conditionals_**

Conditionals are typically used to execute a certain code based on a certain case of actions.

#####**If (if (){ })**

> *The If operator executes code simply of the conditions between the brackets is met.*
```JS
let x = "dog";
if (x == "dog"){
   console.log("X is equal to dog");
}
//Output = "X is equal to dog"
```

#####**Else If(else if (){ })**

> *The Else If operator executes code only if the conditions are met within the statement's brackets, but are not met within any previous statement's brackets.*
```JS
let x = "cat";
if (x == "dog"){
   console.log("X is equal to dog");
}

else if (x == "cat"{
   console.log("X is equal to cat");
}
//Output = "X is equal to cat"
```

#####**Else (else (){ })**

> *The Else operator executes code only if no other if or else if statements are met.*
```JS
let x = "parrot";
if (x == "dog"){
   console.log("X is equal to dog");
}

else if (x == "cat"){
   console.log("X is equal to cat");
}

else (){
   console.log("X is neither a dog nor a cat");
}
//Output = "X is neither a dog nor a cat"
```

###**_JavaScript Loops**

Loops are blocks of code that are run over and over either infinitely or until a condition is met.

#####**For (for (statement 1, statement 2, statement 3){ })**

> *For works as a loop until at least two conditions are met. Statement one usually servers as an initial identifier, and it only run once, statement 2 is usually the statement that tells the loop to stop based on the updated value, statement 3 usually the statement that keeps being run until statement 2 is satisfied.*
```JS
for (i = 0, i < 3, i++){
   console.log(i)
}
//Output = "1"
//Output = "2"
//Output = "3"
```

#####**While (while (){ })**

> *While is simple to understand, as long as the statement within the brackets are true, the statement will keep repeating.*
```JS
while (1 == 1){
   console.log("Looping...")
}
//Output = "Looping..."
//Output = "Looping..."
//Output = "Looping..."
//This will continue infinitely
```