1/*! jQuery v3.6.0 | (c) OpenJS Foundation and other contributors | jquery.org/license */
2!(function (e, t) {
3 "use strict";
4 "object" == typeof module && "object" == typeof module.exports 5 ? (module.exports = e.document
6 ? t(e, !0)
7 : function (e) {
1/*! jQuery v3.6.0 | (c) OpenJS Foundation and other contributors | jquery.org/license */
2!(function (e, t) {
3 "use strict";
4 "object" == typeof module && "object" == typeof module.exports 5 ? (module.exports = e.document
6 ? t(e, !0)
7 : function (e) {
10 return t(e);
11 })
12 : t(e);
13})("undefined" != typeof window ? window : this, function (C, e) { 14 "use strict";
15 var t = [],
16 r = Object.getPrototypeOf,
32 y = {},
33 m = function (e) {
34 return (
35 "function" == typeof e && 36 "number" != typeof e.nodeType &&
37 "function" != typeof e.item
38 );
33 m = function (e) {
34 return (
35 "function" == typeof e &&
36 "number" != typeof e.nodeType && 37 "function" != typeof e.item
38 );
39 },
Yoda conditions are named so because the literal value of the condition comes first while the variable comes second.
For instance,
if ("red" === color) {
// ...
}
Yoda condition is fixed by switching the literal and variable.
This is called a Yoda condition because it reads as, "if red equals the color", similar to the way the Star Wars character Yoda speaks. Compare to the other way of arranging the operands:
if (color === "red") {
// ...
}
This typically reads, "if the color equals red", which is arguably a more natural way to describe the comparison.
if ("red" === color) {
// ...
}
if (true == flag) {
// ...
}
if (5 > count) {
// ...
}
if (-1 < str.indexOf(substr)) {
// ...
}
if (color === "red") {
// ...
}
if (flag === true) {
// ...
}
if (count < 5) {
// ...
}
if (str.indexOf(substr) > -1) {
// ...
}