String 字串

String (通常用單引號包 '文字',雙引號給 HTML)

s1 = "2 + 2";               // creates a string primitive
s2 = new String("2 + 2");   // creates a String object
console.log(eval(s1));      // returns the number 4
console.log(eval(s2));      // returns the string "2 + 2"

來源:https://developer.mozilla.org/zh-TW/docs/Web/JavaScript/Reference/Global_Objects/String

在字串裡也有無法辨識的如下表

Code Output
\0 the NUL character
\' single quote
\" double quote
\\ backslash
\n new line
\r carriage return
\v vertical tab
\t tab
\b backspace
\f form feed
\uXXXX unicode codepoint
\xXX the Latin-1 character

 

Number 文字

即數字,可以做運算、判斷

 

Boolean (true/false)

可以做判斷

Boolean(3 > 2)       // returns true
(3 > 2)              // also returns true
3 > 2                // also returns true
arrow
arrow
    文章標籤
    Javascript 前端
    全站熱搜

    瑞哈 發表在 痞客邦 留言(0) 人氣()