mozilla

Compare Revisions

StringView

Change Revisions

Revision 503555:

Revision 503555 by fusionchess on

Revision 503557:

Revision 503557 by fusionchess on

Title:
StringView
StringView
Slug:
Code_snippets/StringView
Code_snippets/StringView
Tags:
"Code snippet", "MDN JavaScript Libraries", "Sample code", "Guide", "js-ctypes", "WebGL", "JavaScript typed arrays", "JavaScript", "Typed Arrays", "WebSockets"
"Code snippet", "MDN JavaScript Libraries", "Sample code", "Guide", "js-ctypes", "WebGL", "JavaScript typed arrays", "JavaScript", "Typed Arrays", "WebSockets"
Content:

Revision 503555
Revision 503557
nn1086    <h4 id="Examples">
1087      Examples
1088    </h4>
1089    <pre class="brush: js">
1090var myStringView1 = new StringView("Hello world!"); // UTF-8
1091 
1092alert(myStringView) // "Hello world!"
1093 
1094var myStringView2 = new StringView(myStringView1, "UTF-16");
1095 
1096alert(myStringView1.buffer.byteLength); // 12
1097alert(myStringView2.buffer.byteLength); // 24
1098</pre>
t2186</pre>t
2187        <h4 id="Examples">
2188          Examples
2189        </h4>
2190        <pre class="brush: js">
2191var myStringView1 = new StringView("Hello world!"); // UTF-8
2192 
2193alert(myStringView) // "Hello world!"
2194 
2195var myStringView2 = new StringView(myStringView1, "UTF-16");
2196 
2197alert(myStringView1.buffer.byteLength); // 12
2198alert(myStringView2.buffer.byteLength); // 24

Back to History