aboutsummaryrefslogtreecommitdiff
path: root/files/ja/web/javascript/reference/global_objects/string/quote/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'files/ja/web/javascript/reference/global_objects/string/quote/index.html')
-rw-r--r--files/ja/web/javascript/reference/global_objects/string/quote/index.html75
1 files changed, 75 insertions, 0 deletions
diff --git a/files/ja/web/javascript/reference/global_objects/string/quote/index.html b/files/ja/web/javascript/reference/global_objects/string/quote/index.html
new file mode 100644
index 0000000000..2a074faf32
--- /dev/null
+++ b/files/ja/web/javascript/reference/global_objects/string/quote/index.html
@@ -0,0 +1,75 @@
+---
+title: String.prototype.quote()
+slug: Web/JavaScript/Reference/Global_Objects/String/quote
+tags:
+ - String
+ - String Methods
+translation_of: Archive/Web/JavaScript/String.quote
+---
+<div>{{JSRef}} {{obsolete_header("37")}} {{non-standard_header}}</div>
+
+<p>特殊文字をエスケープシーケンスで置換しダブル・クォーテーション(<code>"</code>)でラップした文字列のコピーを返します。</p>
+
+<h2 id="Syntax" name="Syntax">構文</h2>
+
+<pre class="syntaxbox"><code><em>str</em>.quote()</code></pre>
+
+<h3 id="Return_value">Return value</h3>
+
+<p>A new string representing the original string wrapped in double-quotes, with any special characters escaped.</p>
+
+<h2 id="Examples" name="Examples">例</h2>
+
+<p>In the table below thequote()method replaces any special characters and wraps the strings in double-quotes. Also note the third column where a wrapped {{jsxref("Global_Objects/eval", "eval()")}} evaluates the escape sequences again.</p>
+
+<table class="fullwidth-table" style="width: 100%;">
+ <thead>
+ <tr>
+ <th class="header" scope="col"><code>str</code></th>
+ <th class="header" scope="col"><code>str.quote()</code></th>
+ <th class="header" scope="col"><code><a href="/ja/docs/JavaScript/Reference/Global_Objects/eval" title="JavaScript/Reference/Global_Objects/eval">eval</a>( str.quote() )</code></th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><code>Hello world!</code></td>
+ <td><code>"Hello world!"</code></td>
+ <td><code>Hello world!</code></td>
+ </tr>
+ <tr>
+ <td><code>Hello<br>
+         world!</code></td>
+ <td><code>"Hello\n\tworld!"</code></td>
+ <td><code>Hello<br>
+         world!</code></td>
+ </tr>
+ <tr>
+ <td><code>" \ — '</code></td>
+ <td><code>"\" \\ \u2014 '"</code></td>
+ <td><code>" \ — '</code></td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="仕様">仕様</h2>
+
+<p>Not part of any standard. Implemented in JavaScript 1.3.</p>
+
+<h2 id="ポリフィル">ポリフィル</h2>
+
+<pre class="syntaxbox"><code>if (!String.prototype.quote)
+ String.prototype.quote = function(){
+  return JSON.stringify( this ); // since IE8
+</code> }</pre>
+
+<h2 id="ブラウザ互換性情報">ブラウザ互換性情報</h2>
+
+<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>
+
+<p>{{Compat("javascript.builtins.String.quote")}}</p>
+
+<h2 id="関連情報">関連情報</h2>
+
+<ul>
+ <li>{{jsxref("JSON.stringify()")}}</li>
+</ul>