Skip to content

Commit 4a65ca9

Browse files
committed
Update Types page with htmlString and fixed hrefs
1 parent 0b22018 commit 4a65ca9

File tree

1 file changed

+47
-30
lines changed

1 file changed

+47
-30
lines changed

pages/Types.html

+47-30
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
<li class="toclevel-2"><a href="#Boolean_Default"><span class="toctext">Boolean Default</span></a></li>
4444
</ul>
4545
</li>
46+
<li class="toclevel-1"><a href="#htmlString"><span class="toctext">htmlString</span></a></li>
4647
<li class="toclevel-1"><a href="#Number"><span class="toctext">Number</span></a>
4748
<ul>
4849
<li class="toclevel-2"><a href="#Boolean_Default_2"><span class="toctext">Boolean Default</span></a></li>
@@ -93,24 +94,24 @@
9394
</ol>
9495

9596
<h2 id="String"> String </h2>
97+
<p>A string in JavaScript is an immutable object that contains none, one or many characters.
98+
</p>
9699
<pre><code data-lang="javascript">"I'm a String in JavaScript!"
97100
'So am I!'
98101
</code></pre>
99-
<p>A string in JavaScript is an immutable object that contains none, one or many characters.
100-
</p>
101102
<p>The type of a string is "string".
102103
</p>
103104
<pre><code data-lang="javascript">typeof "some string"; // "string"
104105
</code></pre>
105106
<h3 id="Quoting"> Quoting </h3>
106-
<p>A string can be defined using single or double quotes. You can nest single quotes inside of double quotes, and the other way round. To mix double quotes with double quotes, the nested ones have to be escaped with a backslash.
107+
<p>A string can be defined using single or double quotes. You can nest single quotes inside of double quotes, and the other way around. To mix double quotes with double quotes (or single with single), the nested ones have to be escaped with a backslash.
107108
</p>
108109
<pre><code data-lang="javascript">"You make 'me' sad."
109-
'Holy "cranking" moses!'
110+
'That\'s "cranking" good fun!'
110111
"&lt;a href=\"home\"&gt;Home&lt;/a&gt;"
111112
</code></pre>
112113
<h3 id="Built-in_Methods"> Built-in Methods </h3>
113-
<p>A string in JavaScript has some built-in methods to manipulate the string, though the result is always a new string - or something else, eg. split returns an <a href="http://docs.jquery.com/Types#Array" title="Types">array</a>.
114+
<p>A string in JavaScript has some built-in methods to manipulate the string, though the result is always a new string - or something else, eg. split returns an <a href="http://api.jquery.com/Types#Array" title="Types">array</a>.
114115
</p>
115116
<pre><code data-lang="javascript">"hello".charAt( 0 ) // "h"
116117
"hello".toUpperCase() // "HELLO"
@@ -133,12 +134,31 @@ <h3 id="Boolean_Default"> Boolean Default </h3>
133134
!"true" // false
134135
!new Boolean( false ) // false
135136
</code></pre>
137+
138+
<h2 id="htmlString"> htmlString </h2>
139+
<p>A string is designated <strong>htmlString</strong> in jQuery documentation when it is used to represent one or more DOM elements, typically to be created and inserted in the document. When passed as an argument of the <code>jQuery()</code> function, the string is identified as HTML if it starts with <code>&lt;tag ... &gt;</code>) and is parsed as such until the final <code>&gt;</code> character. </p>
140+
<p>For explicit parsing of a string to HTML, the <code><a href="/jQuery.parseHTML/">$.parseHTML()</a></code> method is available as of jQuery 1.8.</p>
141+
<pre><code data-lang="javascript">// Appends <b>hello</b>:
142+
$( "<b>hello</b>" ).appendTo( "body" );
143+
144+
// Appends <b>hello</b>:
145+
$( "<b>hello</b>bye" ).appendTo( "body" );
146+
147+
// Syntax error, unrecognized expression: bye<b>hello</b>
148+
$( "bye<b>hello</b>" ).appendTo( "body" );
149+
150+
// Appends bye<b>hello</b>:
151+
$( $.parseHTML( "bye<b>hello</b>" ) ).appendTo( "body" );
152+
153+
// Appends <b>hello</b>wait<b>bye</b>:
154+
$( "<b>hello</b>wait<b>bye</b>" ).appendTo( "body" );
155+
</code></pre>
136156
<h2 id="Number"> Number </h2>
157+
<p>Numbers in JavaScript are double-precision 64-bit format IEEE 754 values. They are immutable, just as <a href="#String" title="">strings</a>. All operators common in c-based languages are available to work with numbers (+, -, *, /, %, =, +=, -=, *=, /=, ++, --).
158+
</p>
137159
<pre><code data-lang="javascript">12
138160
3.543
139161
</code></pre>
140-
<p>Numbers in JavaScript are double-precision 64-bit format IEEE 754 values. They are immutable, just as <a href="#String" title="">strings</a>. All operators common in c-based languages are available to work with numbers (+, -, *, /, %, =, +=, -=, *=, /=, ++, --).
141-
</p>
142162
<p>The type of a number is "number".
143163
</p>
144164
<pre><code data-lang="javascript">typeof 12 // "number"
@@ -259,8 +279,6 @@ <h3 id="Array_Notation"> Array Notation </h3>
259279
<h3 id="Iteration"> Iteration </h3>
260280
<p>Iterating over objects is easy with the for-in-loop:
261281
</p>
262-
<p><br />
263-
</p>
264282
<pre><code data-lang="javascript">var obj = {
265283
name: "Pete",
266284
age: 15
@@ -271,39 +289,40 @@ <h3 id="Iteration"> Iteration </h3>
271289
</code></pre>
272290
<p>Note that for-in-loop can be spoiled by extending Object.prototype (see <a href="http://erik.eae.net/archives/2005/06/06/22.13.54" class="external text" title="http://erik.eae.net/archives/2005/06/06/22.13.54">Object.prototype is verboten</a>) so take care when using other libraries.
273291
</p>
274-
<p>jQuery provides a generic <a href="http://docs.jquery.com/Utilities/jQuery.each" title="Utilities/jQuery.each">each-function</a> to iterate over properties of objects, as well as elements of arrays:
292+
<p>jQuery provides a generic <a href="http://api.jquery.com/jQuery.each/"><em>each</em> function</a> to iterate over properties of objects, as well as elements of arrays:
275293
</p>
276294
<pre><code data-lang="javascript">jQuery.each( obj, function( key, value ) {
277295
console.log( "key", key, "value", value );
278296
});
279297
</code></pre>
280-
<p>The drawback is that the callback is called in the context of each value, therefore you lose the context of your own object if applicable. More on this below at Functions.
281-
</p>
282-
<p><br />
298+
<p>The drawback is that the callback is called in the context of each value and you therefore lose the context of your own object if applicable. More on this below at Functions.
283299
</p>
300+
284301
<h3 id="Boolean_default_3"> Boolean default </h3>
285302
<p>An object, no matter if it has properties or not, never defaults to false:
286303
</p>
287304
<pre><code data-lang="javascript">!{} // false
288305
!!{} // true
289306
</code></pre>
290307
<h3 id="Prototype"> Prototype </h3>
291-
<p>All objects have a prototype property. Whenever the interpreter looks for a property, it also checks the prototype. jQuery uses that extensively to add methods to jQuery instances.
308+
<p>All objects have a prototype property. Whenever the interpreter looks for a property, it also checks in the object's prototype if the property is not found on the object itself. jQuery uses the prototype extensively to add methods to jQuery instances. Internally, jQuery makes <code>jQuery.fn</code> an alias of <code>jQuery.prototype</code> so you can use either one (though plugin developers have standardized on <code>fn</code>).
292309
</p>
293310
<pre><code data-lang="javascript">var form = $("#myform");
294-
form.clearForm; // undefined
295-
form.fn.clearForm = function() {
311+
console.log( form.clearForm ); // undefined
312+
313+
// jQuery.fn == jQuery.prototype
314+
jQuery.fn.clearForm = function() {
296315
return this.find( ":input" ).each(function() {
297316
this.value = "";
298317
}).end();
299318
};
300-
form.clearForm() // works for all instances of jQuery objects, because the new method was added to the prototype
319+
320+
// works for all instances of jQuery objects, because
321+
// the new method was added to the prototype
322+
console.log( form.clearForm ); // function
323+
form.clearForm();
301324
</code></pre>
302-
<p><br />
303-
(This example needs clarification: how does it modify the prototype when the word "prototype" doesn't appear anywhere? The implication is that form.fn is simply an alias for form.prototype, but if that's the case then it should be explained.&nbsp;:-?)
304-
</p>
305-
<p>In javascript:the definitive guide 5 edition,dont add attibute to Object.prototype
306-
</p>
325+
307326
<h2 id="Array"> Array </h2>
308327
<p>Arrays in JavaScript are mutable lists with a few built-in methods. You can define arrays using the array literal:
309328
</p>
@@ -339,14 +358,14 @@ <h3 id="Iteration_2"> Iteration </h3>
339358
// Do something with item
340359
}
341360
</code></pre>
342-
<p>jQuery provides a generic <a href="http://docs.jquery.com/Utilities/jQuery.each" title="Utilities/jQuery.each">each-function</a> to iterate over element of arrays, as well as properties of objects:
361+
<p>jQuery provides a generic <a href="http://api.jquery.com/jQuery.each/"><em>each</em> function</a> to iterate over element of arrays, as well as properties of objects:
343362
</p>
344363
<pre><code data-lang="javascript">var x = [ 1, 2, 3 ];
345364
jQuery.each( x, function( index, value ) {
346365
console.log( "index", index, "value", value );
347366
});
348367
</code></pre>
349-
<p>The drawback is that the callback is called in the context of each value, therefore you lose the context of your own object if applicable. More on this below at Functions.
368+
<p>The drawback is that the callback is called in the context of each value and you therefore lose the context of your own object if applicable. More on this below at Functions.
350369
</p>
351370
<p>The length property can also be used to add elements to the end of an array. That is equivalent to using the push-method:
352371
</p>
@@ -521,11 +540,9 @@ <h2 id="Callback"> Callback </h2>
521540
<p><br />
522541
</p>
523542
<h2 id="Selector"> Selector </h2>
524-
<p>A selector is used in jQuery to select DOM elements from a DOM document. That document is, in most cases, the DOM document present in all browsers, but can also be a XML document received via AJAX.
525-
</p>
526-
<p>The selectors are a composition of CSS and custom additions. XPath selectors are available as a plugin.
543+
<p>A selector is used in jQuery to select DOM elements from a DOM document. That document is, in most cases, the DOM document present in all browsers, but can also be an XML document received via AJAX.
527544
</p>
528-
<p>All selectors available in jQuery are documented on the <a href="http://docs.jquery.com/Selectors" title="Selectors">Selectors API page</a>.
545+
<p>The selectors are a composition of CSS and custom additions. All selectors available in jQuery are documented on the <a href="http://api.jquery.com/category/selectors" title="Selectors">Selectors API page</a>.
529546
</p>
530547
<p>There are lot of plugins that leverage jQuery's selectors in other ways. The validation plugin accepts a selector to specify a dependency, whether an input is required or not:
531548
</p>
@@ -591,10 +608,10 @@ <h2 id="jqXHR"> jqXHR </h2>
591608
<p>As of jQuery 1.5, the <a href="http://api.jquery.com/jQuery.ajax/">$.ajax()</a> method returns the jqXHR object, which is a superset of the XMLHTTPRequest object. For more information, see the <a href="http://api.jquery.com/jQuery.ajax/#jqXHR">jqXHR section of the $.ajax entry</a>
592609
</p>
593610
<h2 id="Deferred"> Deferred Object</h2>
594-
<p>As of jQuery 1.5, the <a href="http://api.jquery.com/category/deferred-object">Deferred</a> object provides a way to register multiple callbacks into self-managed callback queues, invoke callback queues as appropriate, and relay the success or failure state of any synchronous or asynchronous function.</a>
611+
<p>As of jQuery 1.5, the <a href="http://api.jquery.com/category/deferred-object">Deferred</a> object provides a way to register multiple callbacks into self-managed callback queues, invoke callback queues as appropriate, and relay the success or failure state of any synchronous or asynchronous function.
595612
</p>
596613
<h2 id="Promise"> Promise Object</h2>
597-
<p>This object provides a subset of the methods of the <a href="http://api.jquery.com/category/deferred-object">Deferred</a> object (<a href="http://api.jquery.com/deferred.then/"><code>then</code></a>, <a href="http://api.jquery.com/deferred.done/"><code>done</code></a>, <a href="http://api.jquery.com/deferred.fail/"><code>fail</code></a>, <a href="http://api.jquery.com/deferred.always"><code>always</code></a>, <a href="http://api.jquery.com/deferred.pipe/"><code>pipe</code></a>. <a href="http://api.jquery.com/deferred.isResolved/"><code>isResolved</code></a>, and <a href="http://api.jquery.com/deferred.isRejected/"><code>isRejected</code></a>) to prevent users from changing the state of the Deferred.</a>
614+
<p>This object provides a subset of the methods of the <a href="http://api.jquery.com/category/deferred-object">Deferred</a> object (<a href="http://api.jquery.com/deferred.then/"><code>then</code></a>, <a href="http://api.jquery.com/deferred.done/"><code>done</code></a>, <a href="http://api.jquery.com/deferred.fail/"><code>fail</code></a>, <a href="http://api.jquery.com/deferred.always"><code>always</code></a>, <a href="http://api.jquery.com/deferred.pipe/"><code>pipe</code></a>. <a href="http://api.jquery.com/deferred.isResolved/"><code>isResolved</code></a>, and <a href="http://api.jquery.com/deferred.isRejected/"><code>isRejected</code></a>) to prevent users from changing the state of the Deferred.
598615
</p>
599616
<h2 id="Callbacks">Callbacks Object</h2>
600617
<p>A multi-purpose object that provides a powerful way to manage callback lists. It supports adding, removing, firing, and disabling callbacks. The Callbacks object is created and returned by the <code>$.Callbacks</code> function and subsequently returned by most of that function's methods. </p>

0 commit comments

Comments
 (0)