2013-01-12 141 views

回答

2

你可以用一個反斜槓逃逸,或使用字符串周圍單引號:

var array=["famous quote by Shakespear is","\"to be or not to be\""]; 
var array=["famous quote by Shakespear is",'"to be or not to be"']; 

只要您正確配對,單引號和雙引號就可以互換。

+0

你真棒 – Gordon

2

使用反斜線:

var str = "famous quote by Shakespear is, \"to be or not to be\""; 
var str = 'famous quote by Shakespear is, \'to be or not to be\''; 

或者只混合型報價:

var str = "famous quote by Shakespear is, 'to be or not to be'"; 
var str = 'famous quote by Shakespear is, "to be or not to be"';