JS基礎丨07 字串總結

2021-08-28 17:08:08 字數 1067 閱讀 2818

1. 基本型別:undefined, boolean, number, string;

引用型別:物件,array, date, string, object, function

2. math函式

1. math.random(): 建立乙個隨機數

1. math.round(引數): 引數四捨五入

1. math.abs(引數): 取引數的絕對值

2. math.max(引數,引數,引數,...): 取引數的最大值

2. math.min(引數,引數,引數,...): 取引數的最小值

3. math.ceil(): 向上取整

3. math.floor(): 向下取整

4. math.pow(): 計算乙個數的幾次冪

4. math.sqrt(): 計算乙個數的開方

3. 字元與ascii碼

1. charcodeat(下標): 下標取出的字元 轉 ascii碼

2. string.fromcharcode:

1. ascii碼 轉 化字元

2. 傳多個引數,會根據每個ascii引數生成對應的字元,並且拼接在一起

4. 字串的建立方法

1. 單引號,雙引號建立: typeof: 字串

2. new string()建立: typeof: 物件

05. 字串的操作方法

1. indexof: 子字串在父字串第一次出現的位置;如果沒有就返回-1

1. lastindexof: 子字串在父字串最後一次出現的位置;如果沒有就返回-1

2. tolowercase(): 轉化成小寫字母

2. touppercase(): 轉換成大寫字母

3. concat(): 拼接字串

4. search(): 字串替換

5.substring(): 字串的擷取

6. split(""): 把字串裝換成陣列

JS筆記(2) 字串方法總結

1.substr substr 方法返回乙個字串中從指定位置開始到指定字元數的字元。語法 str.substr start length 引數 其中,start表示開始提取字元的位置。如果為負值,則被看作 strlength start,其中 strlength 為字串的長度 例如,如果 start...

03 字串 基礎

1.string s new string abc 此時記憶體有兩個物件 stringpool裡 abc 堆空間 new string abc string s1 abc 因stringpool裡已經有 abc 物件,所以不會再產生,此時記憶體有兩個物件 string s2 new string a...

python學習手冊筆記 07 字串

00.python字串 乙個有序的字串的集合,用來儲存和表現給予文字的資訊。01.常見字串常量和表示式 s 空字串 s spam s 雙引號和單引號相同 s s n ta x00m 轉移序列 s 三重引號字串塊 s r temp spam raw字串 s b spam s u spam s1 s2 ...