---
# System prepended metadata

title: deno js

---

# deno js




## How to execute .js

- I chose deno to execute

- <b>important:</b> using administrator's access executes a shell


- confirm the shell type
    - window
    ```powershell=
    iwr https://deno.land/x/install/install.ps1 -useb | iex
    ```
    
    - linux
    ```bash=
    curl -fsSL https://deno.land/x/install/install.sh | sh
    ```






## Basic concept

### Data structure

* array vs list
    * array -> Constant length 
    * list -> Elasticity length



### var
var -> local variable
不加 var -> global variable

### Console
- How to print in comsole
```javascript=
x=4
y=9

console.log(x,y) //print variable
```

### list

```javascript=
a[0,1,2,3]
a[2]   //print index of 2 -> 2

a[10]=10  //a[10] -> 0,1,2,3....(empty)......10

```

## Array (just like list, in javascript)

### .push
* Using stack way push data to  a tail list

```javascript=
number[1,2,3,4]
number.push(10) // 10 will add to the tail
```
### .concat

* to connect two arrays

```javascript=
num1 = [1,2,3]
num2 = [4,5,6]
num1.concat(num2)
```

## Function


### Declare Function

- way 1
```javascript=
function add(x,y){
    return x+y;
}
console.log(x,y);
```
- way 2
```javascript=
var sub = function(x,y){
    return x-y=;
}
console.log(10,5)
```

### parameter transmit

* Remark constant wouldn't be fied by function

```javascript=

function  modify(num,array){
    num+=1;
    array[0]+=1;
}
var n=3,a=[3,2,1];
modify(n,a);
console.log(n,a);// n wouldn't change
 
```

### CallFunction


```javascript=
function square(n){
    return n*n;
}

function CallFunction(f,x){
    var Function = f(x);
    console.log("f(x)=" + Function);
   
}

CallFunction(square,5)
```

* Simplification -> MathFunction more 

```javascript=
function square(n){
    return n*n;
}

function CallFunction(f,x){
    //var Function = f(x);
    console.log("f(x)=" + f(x));
   
}

CallFunction(square,5)

```