# 2019/0215/Pre Javascript 基礎 & 在職班補充

## 在職班補充

直譯 腳本 需要時才去讀它

Javacript 通常都是操作這兩大類物件

Document

Window&#x20;

window

Prompt 輸入框

Alert 單按鈕

Confirm 雙按鈕

## 一門語言 語法 撰寫特性 (不包含共同如迴圈陣列...拉

電腦讀完後才顯示

為了整合低網速的移動端現在都改寫在最底層在讀取

js的特性之一為大小寫有不同的意義相較HTML較嚴謹，但又比C鬆散

js撰寫可以省略物件名稱

js宣告不宣告都可用

js宣告後就會給記憶體

js宣告後初始化就會知道他的資料型態&#x20;

ex. m=123 就會知道 m是number型態

js資料型態只有這些 string number boolean

js不用指定資料型態鬆散很好寫但後面很大機會會亂&#x20;

ex. m=123 ; m="adsawqe" ;  上一行是數字型態下一行又能變字串型態

![](/files/-LYijz-02FacoWqek9Jf)

js的undifind是指不存在

js利用前置字元表示進位ex. a=123 //10進 ， b=0123 //8進位 ， c=0678 //8進位帶8那就還是10進位

js的e只是普通字 但c#裡面是保留字

## 物件包含以下&#x20;

屬性 特徵 名詞  (一定一副某個物件

方法 功能 動詞  (方法函數不一定依附物件

事件 觸發&#x20;

### 方法&#x20;

name=prompt("輸入姓名"," ")&#x20;

指定運算子右邊的值丟到左邊

元屬性會給一個undifind值需要給空值削掉

document.write(name)

window\.alert(name)

window就是物件名稱

console能用網頁開發者模式

if () 後面一定要是布林值

用if 判斷這個值是活是死

```
 var k;
        k = 99;
        console.log(k);
        //document.write(k);
        if (k)
            document.write("有定義");
        else
            document.write("沒定義");
```

###

### 建構子

變數沒有類別 建構子，本來就是函數，以function存在 文件物件模型操作屬性

\<h1>                \</h1>

&#x20;       inner Text

###

###

### 遞迴 function自己呼叫自己

## 網頁的動畫其實就是用js去操控css做變化

```
 var car = document.getElementById("car");
        function MyAnimation() {
            var x = car.offsetLeft;
            x += 2;
            car.style.left = x + "px";


            if (car.offsetLeft <= 50) {
                console.log(car.offsetLeft);
                setTimeout(MyAnimation, 10); 

            }
        }

```

console.log(car.offsetLeft)   可以回傳數值做偵錯

## 在職班補充

雖然現在很多語言都支援動態型別 但javascrip的效能比較不好

Javascrip以下都接受

宣告時初始化

先宣告在初始化

純宣告

![](/files/-Lfyb11jcrewHTudcA0a)

Visual Studio方法的圖示&#x20;

prompt() 網頁上彈出提示視窗

選擇敘述&#x20;

IF SWITCH

重複敘述

For while do while

{% embed url="<http://dns2.asia.edu.tw/~wzyang/slides/Java/Hung/java2012-ch05.pdf>" %}

{% embed url="<http://csie2.nhu.edu.tw/files/personal_subject//63_2d8918b0.pdf>" %}

自動顯示時間

![](/files/-LfyaeJEEfNiRh6njwNW)

自動抓取滑鼠作標

![](/files/-LfyalbCtnxmQxfkJWur)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://johch3n611u.gitbook.io/c50108/ju-li-cheng-bei/201902/jscript-ji.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
