---
# System prepended metadata

title: Javascript Notes學習筆記

---

# Javascript Notes學習筆記
Source: [JavaScript for Web Designers](https://www.youtube.com/watch?v=ResWVWI333o) 
By Envato Tuts+ 

## 1.Where?
- Console on browser
- HTML Document (including js tags)
```<script>  </script>```
- Using a dedicated JavaScript file
Create a new file called OOO.js
And in HTML document write down
```<script src="OOO.js"></script>```

## 2.Variables
### declare
``` var x,y,z;```
- **case sensitive**
Estelle is different from estelle.
- **Some words has been declare in this language can't be declared**
```(invalid) var var```
- **Input the value**
``` var x; x= 87;```
## Data type
- **string**
``` var name ="Estelle"```
(You can use single quote and double quote.)
- **number**
``` var age = 18```
(You can also use float number.)
- **boolean**
true | false
```var graduated = false;```
- **null**
If you wanna delete the content of variable-- use "null".
```var age = null ```
- **undefined**
#### typeof
In the console, 
``` typeof name```
it will output "string"

It's a good way to check out the type of a variable.

## Array 
Let's see an example:
``` var list =["Estelle", "Saki", "Max", "Fei", 123, true];```
or create an empty array:
``` list2 =[];```
or create an array like that:
```list3 = new Array(777, false);```

- The first position of array is from 0, just like C++ or Python.
- How many element in this array?
``` list.length ```
- Add new item as the last:
``` list.push("Yay")```
- Add new item as the first:
``` list.unshift()```
- Remove the last item:
``` list.pop()```
- Remove the first item:
``` list.shift()```
- Where is the index? Let's find it out!
```list.indexOf(Estelle)```
And it will display "0".

## Objects