• Home   /  
  • Archive by category "1"

Javascript Double Pipe Assignment Discovery

=

Equals sign

Not equals signAlmost equals sign

currency symbols


Related
In other scripts

"=" and "=" redirect here. For double hyphens, see Double hyphen.

For other uses, see Equals (disambiguation).

For technical reasons, ":=" redirects here. For the computer programming assignment operator, see Assignment (computer science). For the definition symbol, see List of mathematical symbols § Symbols based on equality.

The equals sign or equality sign (=) is a mathematical symbol used to indicate equality. It was invented in 1557 by Robert Recorde. In an equation, the equals sign is placed between two (or more) expressions that have the same value. In Unicode and ASCII, it is U+003D=equals sign (HTML ).

History[edit]

The etymology of the word "equal" is from the Latin word "æqualis" as meaning "uniform", "identical", or "equal", from aequus ("level", "even", or "just").

The "=" symbol that is now universally accepted in mathematics for equality was first recorded by Welsh mathematician Robert Recorde in The Whetstone of Witte (1557). The original form of the symbol was much wider than the present form. In his book Recorde explains his design of the "Gemowe lines" (meaning twin lines, from the Latingemellus[1]):[2]

And to auoide the tediouſe repetition of theſe woordes : is equalle to : I will ſette as I doe often in woorke vſe, a paire of paralleles, or Gemowe lines of one lengthe, thus: =, bicauſe noe .2. thynges, can be moare equalle.

And to avoid the tedious repetition of these words: is equal to: I will set as I do often in work use, a pair of parallels, or Gemowe lines of one length, thus: =, because no 2 things, can be more equal.

According to Scotland's University of St Andrews History of Mathematics website:[3]

The symbol '=' was not immediately popular. The symbol || was used by some and æ (or œ), from the Latin word aequalis meaning equal, was widely used into the 1700s.

Usage in mathematics and computer programming[edit]

In mathematics, the equals sign can be used as a simple statement of fact in a specific case (x = 2), or to create definitions (let x = 2), conditional statements (if x = 2, then …), or to express a universal equivalence .

The first important computer programming language to use the equals sign was the original version of Fortran, FORTRAN I, designed in 1954 and implemented in 1957. In Fortran, "=" serves as an assignment operator: sets the value of to 2. This somewhat resembles the use of "=" in a mathematical definition, but with different semantics: the expression following "=" is evaluated first and may refer to a previous value of . For example, the assignment increases the value of by 2.

A rival programming-language usage was pioneered by the original version of ALGOL, which was designed in 1958 and implemented in 1960. ALGOL included a relational operator that tested for equality, allowing constructions like with essentially the same meaning of "=" as the conditional usage in mathematics. The equals sign was reserved for this usage.

Both usages have remained common in different programming languages into the early 21st century. As well as Fortran, "=" is used for assignment in such languages as C, Perl, Python, awk, and their descendants. But "=" is used for equality and not assignment in the Pascal family, Ada, Eiffel, APL, and other languages.

A few languages, such as BASIC and PL/I, have used the equals sign to mean both assignment and equality, distinguished by context. However, in most languages where "=" has one of these meanings, a different character or, more often, a sequence of characters is used for the other meaning. Following ALGOL, most languages that use "=" for equality use ":=" for assignment, although APL, with its special character set, uses a left-pointing arrow.

Fortran did not have an equality operator (it was only possible to compare an expression to zero, using the arithmetic IF statement) until FORTRAN IV was released in 1962, since when it has used the four characters ".EQ." to test for equality. The language B introduced the use of "==" with this meaning, which has been copied by its descendant C and most later languages where "=" means assignment.

The equals sign is also used in defining attribute–value pairs, in which an attribute is assigned a value.[citation needed]

Usage of several equals signs[edit]

In PHP, the triple equals sign () denotes value and type equality,[4] meaning that not only do the two expressions evaluate to equal values, they are also of the same data type. For instance, the expression is true, but is not, because the number 0 is an integer value whereas false is a Boolean value.

JavaScript has the same semantics for , referred to as "equality without type coercion". However, in JavaScript the behavior of cannot be described by any simple consistent rules. The expression is true, but is false, even though both sides of the act the same in Boolean context. For this reason it is recommended to avoid the operator in JavaScript in favor of .[5]

In Ruby, equality under requires both operands to be of identical type, e.g. is false. The operator is flexible and may be defined arbitrarily for any given type. For example, a value of type is a range of integers, such as . is false, since the types are different (Range vs. Integer); however is true, since on values means "inclusion in the range".[6] Note that under these semantics, is non-symmetric; e.g. is false, since it is interpreted to mean rather than .[7]

Other uses[edit]

The equals sign is sometimes used in Japanese as a separator between names.

Spelling[edit]

Tone letter[edit]

The equals sign is also used as a grammatical tone letter in the orthographies of Budu in the Congo-Kinshasa, in Krumen, Mwan and Dan in the Ivory Coast.[8][9] The Unicode character used for the tone letter (U+A78A)[10] is different from the mathematical symbol (U+003D).

Personal names[edit]

A possibly unique case of the equals sign of European usage in a person's name, specifically in a double-barreled name, was by pioneer aviator Alberto Santos=Dumont, as he is also known not only to have often used an equals sign (=) between his two surnames in place of a hyphen, but also seems to have personally preferred that practice, to display equal respect for his father's French ethnicity and the Brazilian ethnicity of his mother.[11]

Linguistics[edit]

In linguistic interlinear glosses, an equals sign is conventionally used to mark clitic boundaries: the equals sign is placed between the clitic and the word that the clitic is attached to.[12]

Chemistry[edit]

In Chemical formulas, the two parallel lines denoting a double bond are commonly rendered using an equals sign.

Related symbols[edit]

See also: Unicode mathematical operators

Approximately equal[edit]

Main article: Approximation § Unicode

Symbols used to denote items that are approximately equal include the following:[13]

  • ≈ (U+2248, LaTeX\approx)
  • ≃ (U+2243, LaTeX \simeq), a combination of ≈ and =, also used to indicate asymptotic equality
  • ≅ (U+2245, LaTeX \cong), another combination of ≈ and =, which is also sometimes used to indicate isomorphism or congruence
  • ∼ (U+223C), which is also sometimes used to indicate proportionality or similarity, being related by an equivalence relation, or to indicate that a random variable is distributed according to a specific probability distribution (see also tilde)
  • ∽ (U+223D), which is also used to indicate proportionality
  • ≐ (U+2250, LaTeX \doteq), which can also be used to represent the approach of a variable to a limit
  • ≒ (U+2252), commonly used in Japanese, Taiwanese and Korean
  • ≓ (U+2253)

Not equal[edit]

The symbol used to denote inequation (when items are not equal) is a slashed equals sign "≠" (U+2260; 2260,Alt+X in Microsoft Windows). In LaTeX, this is done with the "\neq" command.

Most programming languages, limiting themselves to the 7-bit ASCIIcharacter set and typeable characters, use , , , , or to represent their Booleaninequality operator.

Identity[edit]

The triple bar symbol "≡" (U+2261, LaTeX \equiv) is often used to indicate an identity, a definition (which can also be represented by U+225D "≝" or U+2254 "≔"), or a congruence relation in modular arithmetic. The symbol "≘" can be used to express that an item corresponds to another.

Isomorphism[edit]

The symbol "≅" is often used to indicate isomorphic algebraic structures or congruent geometric figures.

In logic[edit]

Equality of truth values, i.e. bi-implication or logical equivalence, may be denoted by various symbols including =, ~, and ⇔.

Other related symbols[edit]

Additional symbols in Unicode related to the equals sign include:[13]

  • ≌ (U+224C≌ALL EQUAL TO)
  • ≔ (U+2254≔COLON EQUALS) (see also assignment (computer science))
  • ≕ (U+2255≕EQUALS COLON)
  • ≖ (U+2256≖RING IN EQUAL TO)
  • ≗ (U+2257≗RING EQUAL TO)
  • ≙ (U+2259≙ESTIMATES)
  • ≚ (U+225A≚EQUIANGULAR TO)
  • ≛ (U+225B≛STAR EQUALS)
  • ≜ (U+225C≜DELTA EQUAL TO)
  • ≞ (U+225E≞MEASURED BY)
  • ≟ (U+225F≟QUESTIONED EQUAL TO).

Incorrect usage[edit]

The equals sign is sometimes used incorrectly within a mathematical argument to connect math steps in a non-standard way, rather than to show equality (especially by early mathematics students).

For example, if one were finding the sum, step by step, of the numbers 1, 2, 3, 4, and 5, one might incorrectly write

1 + 2 = 3 + 3 = 6 + 4 = 10 + 5 = 15.

Structurally, this is shorthand for

([(1 + 2 = 3) + 3 = 6] + 4 = 10) + 5 = 15,

but the notation is incorrect, because each part of the equality has a different value. If interpreted strictly as it says, it implies

3 = 6 = 10 = 15 = 15.

A correct version of the argument would be

1 + 2 = 3, 3 + 3 = 6, 6 + 4 = 10, 10 + 5 = 15.[14]

Encodings[edit]

  • U+003D=equals sign (HTML )

Related:

  • U+2260≠not equal to (HTML  ·)

See also[edit]

Notes[edit]

  1. ^See also geminus and Gemini.
  2. ^Recorde, Robert, The Whetstone of Witte … (London, England: Jhon Kyngstone, 1557), the third page of the chapter "The rule of equation, commonly called Algebers Rule."
  3. ^"Robert Recorde". MacTutor History of Mathematics archive. Retrieved 19 October 2013. 
  4. ^"Comparison Operators". PHP.net. Retrieved 19 October 2013. 
  5. ^Crockford, Doug. "JavaScript: The Good Parts". YouTube. Retrieved 19 October 2013. 
  6. ^why the lucky stiff. "5.1 This One's For the Disenfranchised". why's (poignant) Guide to Ruby. Retrieved 19 October 2013. 
  7. ^Rasmussen, Brett (30 July 2009). "Don't Call it Case Equality". pmamediagroup.com. Retrieved 19 October 2013. 
  8. ^Peter G. Constable; Lorna A. Priest (31 July 2006). Proposal to Encode Additional Orthographic and Modifier Characters(PDF). Retrieved 19 October 2013. 
  9. ^Hartell, Rhonda L., ed. (1993). The Alphabets of Africa. Dakar: UNESCO and SIL. Retrieved 19 October 2013. 
  10. ^"Unicode Latin Extended-D code chart"(PDF). Unicode.org. Retrieved 19 October 2013. 
  11. ^Gray, Carroll F. (November 2006). "The 1906 Santos=Dumont No. 14bis". World War I Aeroplanes. No. 194: 4. 
  12. ^"Conventions for interlinear morpheme-by-morpheme glosses". Retrieved 2017-11-20. 
  13. ^ ab"Mathematical Operators"(PDF). Unicode.org. Retrieved 19 October 2013. 
  14. ^Capraro, Robert M.; Capraro, Mary Margaret; Yetkiner, Ebrar Z.; Corlu, Sencer M.; Ozel, Serkan; Ye, Sun; Kim, Hae Gyu (2011). "An International Perspective between Problem Types in Textbooks and Students' understanding of relational equality". Mediterranean Journal for Research in Mathematics Education. 10 (1–2): 187–213. Retrieved 19 October 2013. 

References[edit]

External links[edit]

A well-known equality featuring the equals sign
Recorde's introduction of "="
The signature of Santos-Dumont, showing a hyphen that looks like an equal sign.

Types


This page documents data types appearing in jQuery function signatures, whether defined by JavaScript itself or further restricted by jQuery. Unless explicitly stated otherwise, jQuery functions require primitive values where applicable, and do not accept their Object-wrapped forms. If you want to study these concepts in depth, take a look at MDN.

You should be able to try out most of the examples below by just copying them to your browser's JavaScript Console (Chrome, Safari with Develop menu activated, IE 8+) or Firebug console (Firefox).

Whenever an example mentions that a type defaults to a boolean value, the result is good to know when using that type in a boolean context:

1

2

3

4

5

6

In this case, is printed.

To keep the examples short, the invert ("not") operator and double-negation are used to show a boolean context:

1

2

3

On to the actual types.

Contents

  1. Anything
  2. String
  3. htmlString
  4. Number
  5. Boolean
  6. Object
  7. Array
  8. Array-Like Object
  9. PlainObject
  10. Date
  11. Function
  12. Error
  13. Selector
  14. Event
  15. Element
  16. Text
  17. jQuery
  18. XMLHttpRequest
  19. jqXHR
  20. Thenable
  21. Deferred Object
  22. Promise Object
  23. Callbacks Object
  24. XML Document
  25. Qunit's Assert Object

Anything

The Anything virtual type is used in jQuery documentation to indicate that any type can be used or should be expected.

String

A string in JavaScript is an immutable primitive value that contains none, one or many characters.

1

2

The type of a string is "string".

1

Quoting

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.

1

2

3

Built-in Methods

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 array.

1

2

3

4

5

Length Property

All strings have a length property.

1

2

Boolean Default

An empty string defaults to false:

1

2

3

4

5

htmlString

A string is designated htmlString 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 function, the string is identified as HTML if it starts with ) and is parsed as such until the final character. Prior to jQuery 1.9, a string was considered to be HTML if it contained anywhere within the string.

When a string as passed as an argument to a manipulation method such as , it is always considered to be HTML since jQuery's other common interpretation of a string (CSS selectors) does not apply in those contexts.

For explicit parsing of a string to HTML, the method is available as of jQuery 1.8.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

Number

Numbers in JavaScript are double-precision 64-bit format IEEE 754 values. They are immutable primitive values, just like strings. All operators common in c-based languages are available to work with numbers (+, -, *, /, %, =, +=, -=, *=, /=, ++, --).

The type of a number is "number".

1

2

Boolean Default

If a number is zero, it defaults to false:

Due to the implementation of numbers as double-precision values, the following result is not an error:

Math

JavaScript provides utilities to work with numbers in the Math object:

1

2

Parsing Numbers

parseInt and parseFloat help parsing strings into numbers. Both do some implicit conversion if the base isn't specified:

1

2

3

4

5

6

Numbers to Strings

When appending numbers to string, the result is always a string. The operator is the same, so be careful: If you want to add numbers and then append them to a string, put parentheses around the numbers:

1

2

3

4

Or you use the String class provided by javascript, which try to parse a value as string:

1

2

NaN and Infinity

Parsing something that isn't a number results in NaN. isNaN helps to detect those cases:

1

2

Division by zero results in Infinity:

Both NaN and Infinity are of type "number":

1

2

Note that NaN compares in a strange way:

But:

Integer

An integer is a plain Number type, but whenever explicitly mentioned, indicates that a non-floating-point number is expected.

Float

A float is a plain Number type, just as Integer, but whenever explicitly mentioned, indicates that a floating-point number is expected.

Boolean

A boolean in JavaScript can be either true or false:

1

2

Object

Everything in JavaScript is an object, though some are more objective (haha). The easiest way to create an object is the object literal:

1

2

3

4

5

The type of an object is "object":

Dot Notation

You can write and read properties of an object using the dot notation:

1

2

3

4

Array Notation

Or you write and read properties using the array notation, which allows you to dynamically choose the property:

1

2

3

4

5

6

7

Iteration

Iterating over objects is easy with the for-in-loop:

1

2

3

4

5

6

7

Note that for-in-loop can be spoiled by extending Object.prototype (see Object.prototype is verboten) so take care when using other libraries.

jQuery provides a generic each function to iterate over properties of objects, as well as elements of arrays:

1

2

3

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.

Boolean default

An object, no matter if it has properties or not, never defaults to false:

Prototype

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 an alias of so you can use either one (though plugin developers have standardized on ).

1

2

3

4

5

6

7

8

9

10

11

12

13

14

Array

Arrays in JavaScript are mutable lists with a few built-in methods. You can define arrays using the array literal:

1

2

The type of an array is "object":

1

2

Reading and writing elements to an array uses the array-notation:

Iteration

An array has a length property that is useful for iteration:

1

2

3

When performance is critical, reading the length property only once can help to speed things up. This should be used only when a performance bottleneck was discovered:

1

2

3

Another variation defines a variable that is filled for each iteration, removing the array-notation from the loop-body. It does not work when the array contains 0 or empty strings!

1

2

3

jQuery provides a generic each function to iterate over element of arrays, as well as properties of objects:

1

2

3

4

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.

The length property can also be used to add elements to the end of an array. That is equivalent to using the push-method:

1

2

3

4

You'll see both variations a lot when looking through JavaScript library code.

Other built-in methods are reverse, join, shift, unshift, pop, slice, splice and sort:

1

2

3

4

5

6

7

8

Note: .unshift() method does not return a length property in Internet Explorer.

Boolean Default

An array, no matter if it has elements or not, never defaults to false:

Array<Type> Notation

In the jQuery API you'll often find the notation of Array<Type>:

dragPrevention Array<String>

This indicates that the method doesn't only expect an array as the argument, but also specifies the expected type. The notation is borrowed from Java 5's generics notation (or C++ templates).

Array-Like Object

Either a true JavaScript Array or a JavaScript Object that contains a nonnegative integer property and index properties from up to . This latter case includes array-like objects commonly encountered in web-based code such as the object and the object returned by many DOM methods.

When a jQuery API accepts either plain Objects or Array-Like objects, a plain Object with a numeric property will trigger the Array-Like behavior.

PlainObject

The PlainObject type is a JavaScript object containing zero or more key-value pairs. The plain object is, in other words, an object. It is designated "plain" in jQuery documentation to distinguish it from other kinds of JavaScript objects: for example, , user-defined arrays, and host objects such as , all of which have a value of "object." The method identifies whether the passed argument is a plain object or not, as demonstrated below:

1

2

3

4

5

6

7

8

9

10

11

Null

The keyword is a JavaScript literal that is commonly used to express the absence of an intentional value.

Date

The Date type is a JavaScript object that represents a single moment in time. Date objects are instantiated using their constructor function, which by default creates an object that represents the current date and time.

To create a Date object for an alternative date and time, pass numeric arguments in the following order: year, month, day, hour, minute, second, millisecond — although note that the month is zero-based, whereas the other arguments are one-based. The following creates a Date object representing January 1st, 2014, at 8:15.

1

Function

A function in JavaScript can be either named or anonymous. Any function can be assigned to a variable or passed to a method, but passing member functions this way can cause them to be called in the context of another object (i.e. with a different "this" object).

1

2

You see a lot of anonymous functions in jQuery code:

1

2

3

4

5

6

The type of a function is "function".

Arguments

Inside a function a special variable "arguments" is always available. It's similar to an array in that it has a length property, but it lacks the built-in methods of an array. The elements of the pseudo-array are the argument of the function call.

1

2

3

4

5

6

The arguments object also has a callee property, which refers to the function you're inside of. For instance:

1

2

Context, Call and Apply

In JavaScript, the variable "this" always refers to the current context. By default, "this" refers to the window object. Within a function this context can change, depending on how the function is called.

All event handlers in jQuery are called with the handling element as the context.

1

2

3

4

5

6

You can specify the context for a function call using the function-built-in methods call and apply. The difference between them is how they pass arguments. Call passes all arguments through as arguments to the function, while apply accepts an array as the arguments.

1

2

3

4

5

6

Scope

In JavaScript, all variables defined inside a function are only visible inside that function scope. Consider the following example:

1

2

3

4

5

6

7

8

It defines a variable x in the global scope, then defines an anonymous function and executes it immediately (the additional parentheses are required for immediate execution). Inside the function another variable x is defined with a different value. It is only visible within that function and doesn't overwrite the global variable.

Closures

Closures are created whenever a variable that is defined outside the current scope is accessed from within some inner scope. In the following example, the variable counter is visible within the create, increment, and print functions, but not outside of them.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

The pattern allows you to create objects with methods that operate on data that isn't visible to the outside—the very basis of object-oriented programming.

Proxy Pattern

Combining the above knowledge gives you as a JavaScript developer quite a lot of power. One way to combine that is to implement a proxy pattern in JavaScript, enabling the basics of aspect-oriented programming (AOP):

1

2

3

4

5

6

7

8

The above wraps its code in a function to hide the "proxied"-variable. It saves jQuery's setArray-method in a closure and overwrites it. The proxy then logs all calls to the method and delegates the call to the original. Using apply(this, arguments) guarantees that the caller won't be able to notice the difference between the original and the proxied method.

Callback

A callback is a plain JavaScript function passed to some method as an argument or option. Some callbacks are just events, called to give the user a chance to react when a certain state is triggered. jQuery's event system uses such callbacks everywhere:

1

2

3

Most callbacks provide arguments and a context. In the event-handler example, the callback is called with one argument, an Event. The context is set to the handling element, in the above example, document.body.

Some callbacks are required to return something, others make that return value optional. To prevent a form submission, a submit event handler can return false:

1

2

3

Instead of always returning false, the callback could check fields of the form for validity, and return false only when the form is invalid.

Error

An instance of an Error object is thrown as an exception when a runtime error occurs. Error can also be used as base to define user custom exception classes. In JavaScript an error can be thrown as shown below:

1

An error can also be thrown by the engine under some circumstances. For example, when trying to access a property of :

1

2

Selector

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.

The selectors are a composition of CSS and custom additions. All selectors available in jQuery are documented on the Selectors API page.

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:

1

2

3

This would make a checkbox with name "emailrules" required only if the user entered an email address in the email field, selected via its id, filtered via a custom selector ":filled" that the validation plugin provides.

If Selector is specified as the type of an argument, it accepts everything that the jQuery constructor accepts, eg. Strings, Elements, Lists of Elements.

Event

jQuery's event system normalizes the event object according to W3C standards. The event object is guaranteed to be passed to the event handler (no checks for window.event required). It normalizes the target, relatedTarget, which, metaKey and pageX/Y properties and provides both stopPropagation() and preventDefault() methods.

Those properties are all documented, and accompanied by examples, on the Event object page.

The standard events in the Document Object Model are: , , , , , , , , , , , , , , , , , , , , and . Since the DOM event names have predefined meanings for some elements, using them for other purposes is not recommended. jQuery's event model can trigger an event by any name on an element, and it is propagated up the DOM tree to which that element belongs, if any.

Element

An element in the Document Object Model (DOM) can have attributes, text, and children. It provides methods to traverse the parent and children and to get access to its attributes. Due to inconsistencies in DOM API specifications and implementations, however, those methods can be a challenge to use. jQuery provides a "wrapper" around those elements to help interacting with the DOM. But sometimes you will be working directly with DOM elements, or see methods that (also) accept DOM elements as arguments.

Whenever you call jQuery's method or one of its event methods on a jQuery collection, the context of the callback function — — is set to a DOM element.

Some properties of DOM elements are quite consistent among browsers. Consider this example of a simple onblur validation:

1

2

3

4

5

You could replace with to access the value of the text input via jQuery, but in that case you wouldn't gain anything.

Text

Text is a node of the Document Object Model (DOM) that represents the textual content of an element or an attribute. Consider the following code:

1

If you retrieve the children of the paragraph of the example as follows:

1

you obtain two children. The first one is the element representing the tag. The second child is a text node containing the string " world".

jQuery

A jQuery object contains a collection of Document Object Model (DOM) elements that have been created from an HTML string or selected from a document. Since jQuery methods often use CSS selectors to match elements from a document, the set of elements in a jQuery object is often called a set of "matched elements" or "selected elements".

The jQuery object itself behaves much like an array; it has a property and the elements in the object can be accessed by their numeric indices to . Note that a jQuery object is not actually a Javascript Array object, so it does not have all the methods of a true Array object such as .

Most frequently, you will use the jQuery() function to create a jQuery object. can also be accessed by its familiar single-character alias of , unless you have called to disable this option. Many jQuery methods return the jQuery object itself, so that method calls can be chained:

In API calls that return , the value returned will be the original jQuery object unless otherwise documented by that API. API methods such as or modify their incoming set and thus return a new jQuery object.

1

Whenever you use a "destructive" jQuery method that potentially changes the set of elements in the jQuery object, such as or , that method actually returns a new jQuery object with the resulting elements. To return to the previous jQuery object, you use the method.

A jQuery object may be empty, containing no DOM elements. You can create an empty jQuery object with (that is, passing no arguments at all). A jQuery object may also be empty if a selector doesn't select any elements, or if a chained method filters out all the elements. It is not an error; any further methods called on that jQuery object simply have no effect since they have no elements to act upon. So, in this example if there are no bad entries on the page then no elements will be colored red:

1

XMLHttpRequest

Some of jQuery's Ajax functions return the native XMLHttpRequest (XHR) object, or pass it as an argument to success/error/complete handlers, so that you can do additional processing or monitoring on the request. Note that Ajax functions only return or pass an XHR object when an XHR object is actually used in the request. For example, JSONP requests and cross-domain GET requests use a script element rather than an XHR object.

Although the XHR object is a standard, there are variations in its behavior on different browsers. Refer to the WHATWG site and browsers' documentation for more information:

Google does not appear to have an official page for their XHR documentation for Chrome. As of version 5, Chrome does not support the use of the file protocol for XHR requests.

jqXHR

As of jQuery 1.5, the $.ajax() method returns the jqXHR object, which is a superset of the XMLHTTPRequest object. For more information, see the jqXHR section of the $.ajax entry

Thenable

Any object that has a method.

Deferred Object

As of jQuery 1.5, the Deferred 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.

Promise Object

This object provides a subset of the methods of the Deferred object (, , , , , , and ) to prevent users from changing the state of the Deferred.

Callbacks Object

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 function and subsequently returned by most of that function's methods.

XML Document

A document object created by the browser's XML DOM parser, usually from a string representing XML. XML documents have different semantics than HTML documents, but most of the traversing and manipulation methods provided by jQuery will work with them.

Assert

A reference to or instance of the object holding all of QUnit's assertions. See the API documentation for for details.

One thought on “Javascript Double Pipe Assignment Discovery

Leave a comment

L'indirizzo email non verrà pubblicato. I campi obbligatori sono contrassegnati *