From 8f2731905212f6e7eb2d9793ad20b8b448c54ccf Mon Sep 17 00:00:00 2001 From: Florian Merz Date: Thu, 11 Feb 2021 14:51:31 +0100 Subject: unslug tr: move --- .../reference/global_objects/boolean/index.html | 77 +++ .../reference/global_objects/map/index.html | 85 ++++ .../web/javascript/reference/operators/index.html | 294 +++++++++++ .../index.html | 565 +++++++++++++++++++++ .../index.html | 312 ++++++++++++ 5 files changed, 1333 insertions(+) create mode 100644 files/tr/conflicting/web/javascript/reference/global_objects/boolean/index.html create mode 100644 files/tr/conflicting/web/javascript/reference/global_objects/map/index.html create mode 100644 files/tr/conflicting/web/javascript/reference/operators/index.html create mode 100644 files/tr/conflicting/web/javascript/reference/operators_3b90ea9617c66e4283e266b64ea7ae4a/index.html create mode 100644 files/tr/conflicting/web/javascript/reference/operators_603c79383d36dadbe5083df806de5999/index.html (limited to 'files/tr/conflicting/web/javascript') diff --git a/files/tr/conflicting/web/javascript/reference/global_objects/boolean/index.html b/files/tr/conflicting/web/javascript/reference/global_objects/boolean/index.html new file mode 100644 index 0000000000..dcb92f48b3 --- /dev/null +++ b/files/tr/conflicting/web/javascript/reference/global_objects/boolean/index.html @@ -0,0 +1,77 @@ +--- +title: Boolean.prototype +slug: Web/JavaScript/Reference/Global_Objects/Boolean/prototype +translation_of: Web/JavaScript/Reference/Global_Objects/Boolean +translation_of_original: Web/JavaScript/Reference/Global_Objects/Boolean/prototype +--- +
{{JSRef}}
+ +

Boolean.prototype özelliği {{jsxref ("Boolean")}} yapıcı methodunun prototipini temsil eder.

+ +
{{js_property_attributes(0, 0, 0)}}
+ +
{{EmbedInteractiveExample("pages/js/boolean-constructor.html")}}
+ + + +

 

+ +

{{jsxref("Boolean")}} instances inherit from Boolean.prototype. You can use the constructor's prototype object to add properties or methods to all {{jsxref("Boolean")}} instances.

+ +

Properties

+ +
+
Boolean.prototype.constructor
+
Bir örneğin prototipini oluşturan fonksiyonu döndürür. Bu varsayılan olarak {{jsxref ("Boolean")}} işlevidir.
+
+ +

Methods

+ +
+
{{jsxref("Boolean.prototype.toSource()")}} {{non-standard_inline}}
+
{{Jsxref ("Boolean")}} nesnesinin kaynağını içeren bir dize döndürür; eşdeğer bir nesne oluşturmak için bu dizeyi kullanabilirsiniz. {{Jsxref ("Object.prototype.toSource ()")}} methodunu geçersiz kılar.
+
{{jsxref("Boolean.prototype.toString()")}}
+
Nesnenin değerine bağlı olarak "true" ya da "false" dizesini döndürür. {{Jsxref ("Object.prototype.toString ()")}} methodunu geçersiz kılar.
+
{{jsxref("Boolean.prototype.valueOf()")}}
+
{{Jsxref ("Boolean")}} nesnesinin temel değerini döndürür. {{Jsxref ("Object.prototype.valueOf ()")}} methodunu geçersiz kılar.
+
+ +

Özellikler

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ÖzelliklerDurumAçıklama
{{SpecName('ES1')}}{{Spec2('ES1')}}İlk tanım. JavaScript 1.0'da uygulanmaktadır.
{{SpecName('ES5.1', '#sec-15.6.3.1', 'Boolean.prototype')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-boolean.prototype', 'Boolean.prototype')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-boolean.prototype', 'Boolean.prototype')}}{{Spec2('ESDraft')}} 
+ +

Tarayıcı Uyumluluğu

+ +
+ + +

{{Compat("javascript.builtins.Boolean.prototype")}}

+
diff --git a/files/tr/conflicting/web/javascript/reference/global_objects/map/index.html b/files/tr/conflicting/web/javascript/reference/global_objects/map/index.html new file mode 100644 index 0000000000..1124f3602e --- /dev/null +++ b/files/tr/conflicting/web/javascript/reference/global_objects/map/index.html @@ -0,0 +1,85 @@ +--- +title: Map.prototype +slug: Web/JavaScript/Reference/Global_Objects/Map/prototype +translation_of: Web/JavaScript/Reference/Global_Objects/Map +translation_of_original: Web/JavaScript/Reference/Global_Objects/Map/prototype +--- +
{{JSRef}}
+ +

Map.prototype özelliği {{jsxref("Map")}} kurucusunun prototipini temsil eder.

+ +
{{js_property_attributes(0,0,0)}}
+ +

Tanım

+ +

{{jsxref("Map")}} örnekleri {{jsxref("Map.prototype")}}'den miras alınır. Tüm Map örneklerine özellikler veya yöntemler eklemek için yapıcının prototip nesnesini kullanabilirsiniz.

+ +

Özellikleri

+ +
+
Map.prototype.constructor
+
Bir örneğin prototipini oluşturan işlevi döndürür. Bu, varsayılan olarak {{jsxref("Map")}} işlevidir.
+
{{jsxref("Map.prototype.size")}}
+
Map nesnesindeki anahtar / değer çiftlerinin sayısını döndürür.
+
+ +

Yöntemler

+ +
+
{{jsxref("Map.prototype.clear()")}}
+
Tüm anahtar / değer çiftlerini Map objesinden siler.
+
{{jsxref("Map.delete", "Map.prototype.delete(key)")}}
+
Map nesnesindeki bir öge varsa ve kaldırılmışsa true öge yoksa false döndürür. Map.prototype.has(key) daha sonra false döndürür.
+
{{jsxref("Map.prototype.entries()")}}
+
Ekleme sırasındaki Map nesnesindeki her öge için [anahtar, değer] dizisini içeren yeni bir Iterator nesnesini döndürür.
+
{{jsxref("Map.forEach", "Map.prototype.forEach(callbackFn[, thisArg])")}}
+
Map nesnesindeki her anahtar - değer çifti için ekleme sırasına göre callbackFn ögesini bir kez çağırır.  thisArg parametresi forEach için sağlanmışsa, her geri çağırma için bu değer olarak kullanılacaktır.
+
{{jsxref("Map.get", "Map.prototype.get(key)")}}
+
key ile ilişkilendirilmiş değeri veya hiçbir şey yoksa undefined değerini döndürür.
+
{{jsxref("Map.has", "Map.prototype.has(key)")}}
+
Map nesnesindeki bir değerin key ile ilişkili olup olmadığını belirten bir boolean döndürür.
+
{{jsxref("Map.prototype.keys()")}}
+
Map nesnesindeki her bir ögenin anahtarlarını ekleme sırasına göre içeren yeni bir Iterator nesnesi döndürür.
+
{{jsxref("Map.set", "Map.prototype.set(key, value)")}}
+
Mapnesnesindeki key değerini ayarlar. Map nesnesini döndürür.
+
{{jsxref("Map.prototype.values()")}}
+
Map nesnesindeki her bir ögenin değerlerini ekleme sırasına göre içeren yeni bir  Iterator nesnesi döndürür.
+
{{jsxref("Map.@@iterator", "Map.prototype[@@iterator]()")}}
+
Ekleme sırasındaki Map nesnesindeki her bir öge için[anahtar, değer] dizisini içeren yeni bir Iterator nesnesini döndürür.
+
+ +

Şartlar

+ + + + + + + + + + + + + + + + + + + +
ŞartDurumAçıklama
{{SpecName('ES2015', '#sec-map.prototype', 'Map.prototype')}}{{Spec2('ES2015')}} +

İlk tanım

+
{{SpecName('ESDraft', '#sec-map.prototype', 'Map.prototype')}}{{Spec2('ESDraft')}} 
+ +

Tarayıcı Uyumluluğu

+ + + +

{{Compat("javascript.builtins.Map.prototype")}}

+ +

Ayrıca Bakınız

+ + diff --git a/files/tr/conflicting/web/javascript/reference/operators/index.html b/files/tr/conflicting/web/javascript/reference/operators/index.html new file mode 100644 index 0000000000..04d337601d --- /dev/null +++ b/files/tr/conflicting/web/javascript/reference/operators/index.html @@ -0,0 +1,294 @@ +--- +title: Arithmetic operators +slug: Web/JavaScript/Reference/Operatörler/Arithmetic_Operators +tags: + - Aritmetik Operatörler + - JavaScript +translation_of: Web/JavaScript/Reference/Operators +translation_of_original: Web/JavaScript/Reference/Operators/Arithmetic_Operators +--- +
{{jsSidebar("Operators")}}
+ +

Aritmetik operatörler sayısal değerleri (değişmez değerler veya değişkenler) kendi değişkeni olarak alır ve tek bir sayısal değer döndürür. Standart aritmetik operatörler toplama (+), çıkarma (-), çıkarma (*), ve bölme (/).

+ +
{{EmbedInteractiveExample("pages/js/expressions-arithmetic.html")}}
+ + + +

Toplama (+)

+ +

Toplama işleci, sayısal değişkenlerin veya dize birleşiminin toplamını üretir.

+ +

Syntax

+ +
Operator: x + y
+
+ +

Examples

+ +
// Number + Number -> Toplama
+1 + 2 // 3
+
+// Boolean + Number -> Toplama
+true + 1 // 2
+
+// Boolean + Boolean -> Toplama
+false + false // 0
+
+// Number + String -> Birleşim
+5 + 'foo' // "5foo"
+
+// String + Boolean -> Birleşim
+'foo' + false // "foofalse"
+
+// String + String -> Birleşim
+'foo' + 'bar' // "foobar"
+
+ +

Çıkarma (-)

+ +

Çıkarma işleci (operator), iki değişkeni çıkarır ve farklarını üretir.

+ +

Söz Dizimi

+ +
Operator: x - y
+
+ +

Örnekler

+ +
5 - 3 // 2
+3 - 5 // -2
+'foo' - 3 // NaN(Sayı Değil)
+ +

Bölme (/)

+ +

Bölme operatörü, sol değişkenin bölüm olduğu ve sağ değişkenin bölen olduğu işlenenlerin bölümünü üretir.

+ +

Söz Dizimi

+ +
Operator: x / y
+
+ +

Örnekler

+ +
1 / 2      // 0.5 döndürür
+1 / 2      // Java''da 0 döndürür
+// (her iki sayı da açıkça kayan nokta sayısıdır)
+
+1.0 / 2.0  // JavaScript ve Java 0.5 döndürür
+
+2.0 / 0    // JavaScript sonsuz döndürür
+2.0 / 0.0  // Sonsuzu da döndürür
+2.0 / -0.0 // JavaScript eksi sonsuz da döndürür
+ +

Çarpma (*)

+ +

Çarpma operatörü değişkenlerin ürününü üretir.

+ +

Söz Dizimi

+ +
Operator: x * y
+
+ +

Örnekler

+ +
2 * 2 // 4
+-2 * 2 // -4
+Infinity * 0 // NaN(Sayı Değil1)
+Infinity * Infinity // Sonsuz
+'foo' * 2 // NaN
+
+ +

Kalan (%)

+ +

Kalan operatörü, bir değişken ikinci bir değişken tarafından bölündüğünde kalan döndürür. Her zaman bölüm işareti alır.

+ +

Söz Dizimi

+ +
Operator: var1 % var2
+
+ +

Örnekler

+ +
12 % 5 // 2
+-1 % 2 // -1
+1 % -2 // 1
+NaN % 2 // NaN
+1 % 2 // 1
+2 % 3 // 2
+-4 % 2 // -0
+5.5 % 2 // 1.5
+
+ +

Üs (**)

+ +

The exponentiation operator returns the result of raising first operand to the power second operand. That is, var1var2, in the preceding statement, where var1 and var2 are variables. Exponentiation operator is right associative. a ** b ** c is equal to a ** (b ** c).

+ +

Syntax

+ +
Operator: var1 ** var2
+
+ +

Notes

+ +

In most languages like PHP and Python and others that have an exponentiation operator (**), the exponentiation operator is defined to have a higher precedence than unary operators such as unary + and unary -, but there are a few exceptions. For example, in Bash the ** operator is defined to have a lower precedence than unary operators. In JavaScript, it is impossible to write an ambiguous exponentiation expression, i.e. you cannot put a unary operator (+/-/~/!/delete/void/typeof) immediately before the base number.

+ +
-2 ** 2;
+// 4 in Bash, -4 in other languages.
+// This is invalid in JavaScript, as the operation is ambiguous.
+
+
+-(2 ** 2);
+// -4 in JavaScript and the author's intention is unambiguous.
+
+ +

Examples

+ +
2 ** 3 // 8
+3 ** 2 // 9
+3 ** 2.5 // 15.588457268119896
+10 ** -1 // 0.1
+NaN ** 2 // NaN
+
+2 ** 3 ** 2 // 512
+2 ** (3 ** 2) // 512
+(2 ** 3) ** 2 // 64
+
+ +

To invert the sign of the result of an exponentiation expression:

+ +
-(2 ** 2) // -4
+
+ +

To force the base of an exponentiation expression to be a negative number:

+ +
(-2) ** 2 // 4
+
+ +
+

Note: JavaScript also has a bitwise operator ^ (logical XOR). ** and ^ are different (for example : 2 ** 3 === 8 when 2 ^ 3 === 1.)

+
+ +

Artırma (++)

+ +

Artış operatörü işlenenini artırır (bir ekler) ve bir değer döndürür.

+ + + +

Söz Dizimi

+ +
Operator: x++ yada ++x
+
+ +

Örnekler

+ +
// Postfix
+var x = 3;
+y = x++; // y = 3, x = 4
+
+// Prefix
+var a = 2;
+b = ++a; // a = 3, b = 3
+
+ +

Azaltma (--)

+ +

The decrement operator decrements (subtracts one from) its operand and returns a value.

+ + + +

Syntax

+ +
Operator: x-- or --x
+
+ +

Examples

+ +
// Postfix
+var x = 3;
+y = x--; // y = 3, x = 2
+
+// Prefix
+var a = 2;
+b = --a; // a = 1, b = 1
+
+ +

Unary negation (-)

+ +

The unary negation operator precedes its operand and negates it.

+ +

Syntax

+ +
Operator: -x
+
+ +

Examples

+ +
var x = 3;
+y = -x; // y = -3, x = 3
+
+// Unary negation operator can convert non-numbers into a number
+var x = "4";
+y = -x; // y = -4
+
+ +

Unary plus (+)

+ +

The unary plus operator precedes its operand and evaluates to its operand but attempts to convert it into a number, if it isn't already. Although unary negation (-) also can convert non-numbers, unary plus is the fastest and preferred way of converting something into a number, because it does not perform any other operations on the number. It can convert string representations of integers and floats, as well as the non-string values true, false, and null. Integers in both decimal and hexadecimal ("0x"-prefixed) formats are supported. Negative numbers are supported (though not for hex). If it cannot parse a particular value, it will evaluate to {{jsxref("NaN")}}.

+ +

Syntax

+ +
Operator: +x
+
+ +

Examples

+ +
+3     // 3
++'3'   // 3
++true  // 1
++false // 0
++null  // 0
++function(val){ return val } // NaN
+
+ +

Specifications

+ + + + + + + + + + + + + + + + + + + + + +
Specification
{{SpecName('ESDraft', '#sec-additive-operators', 'Additive operators')}}
{{SpecName('ESDraft', '#sec-postfix-expressions', 'Postfix expressions')}}
{{SpecName('ESDraft', '#sec-11.5', 'Multiplicative operators')}}
{{SpecName('ESDraft', '#sec-11.4', 'Unary operator')}}
+ +

Browser compatibility

+ + + +

{{Compat("javascript.operators.arithmetic")}}

+ +

See also

+ + diff --git a/files/tr/conflicting/web/javascript/reference/operators_3b90ea9617c66e4283e266b64ea7ae4a/index.html b/files/tr/conflicting/web/javascript/reference/operators_3b90ea9617c66e4283e266b64ea7ae4a/index.html new file mode 100644 index 0000000000..410107226b --- /dev/null +++ b/files/tr/conflicting/web/javascript/reference/operators_3b90ea9617c66e4283e266b64ea7ae4a/index.html @@ -0,0 +1,565 @@ +--- +title: Bitwise operators +slug: Web/JavaScript/Reference/Operatörler/Bitwise_Operators +translation_of: Web/JavaScript/Reference/Operators +translation_of_original: Web/JavaScript/Reference/Operators/Bitwise_Operators +--- +
{{jsSidebar("Operators")}}
+ +

Bitsel işleçler işlediği elemanlara ondalık, onaltılık veya sayılar yerine 32 bit diziler(sıfır ve birler) olarak davranır. Örneğin, onluk bir sayı olan 9, ikilik sistemde 1001 ile gösterilir. Bitsel işleçler, işlemin iki tarafınada ikili değerleriyle işlem yapar ancak JavaScript standartı olan sayısal değerleri döner.

+ +

Aşağıdaki tablo JavaScript'in bitsel işleçlerini özetler:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
OperatorUsageDescription
Bitwise ANDa & bBitsel işleçin iki tarafının karşılık gelen bitleri 1 ise, en az bir tanesi 0 ise 0 döndürür.
Bitwise ORa | bBitsel işleçin iki tarafının karşılık gelen bitlerinden en az biri 1 ise 1 döndürür.
Bitwise XORa ^ bBitsel işleçin iki tarafının karşılık gelen bitlerinden ancak bir tanesi 1 ise, 1 döndürür.
Bitwise NOT~ aİşlenenin bitlerini ters çevirir.
Left shifta << ba sayısının ikili haline, sağına b (< 32) adet bit 0 ekleyerek sola doğru kaydırır.
Sign-propagating right shifta >> ba sayısının ikili halini b (< 32) adet bit sağa kaydırır. Pozitif sayılar için b adet 0, negatif sayılar için 1 ekleyerek kaydırır.
Zero-fill right shifta >>> ba sayısının ikili gösterimine b (< 32) bit sağa kaydırır, a sayısının pozitif negatif olmasına bakmadan sayının soluna b adet 0 ekler.
+ +

İşaretli 32-bit integer sayılar

+ +

The operands of all bitwise operators are converted to signed 32-bit integers in two's complement format. Two's complement format means that a number's negative counterpart (e.g. 5 vs. -5) is all the number's bits inverted (bitwise NOT of the number, a.k.a. ones' complement of the number) plus one. For example, the following encodes the integer 314:

+ +
00000000000000000000000100111010
+
+ +

The following encodes ~314, i.e. the ones' complement of -314:

+ +
11111111111111111111111011000101
+
+ +

Finally, the following encodes -314, i.e. the two's complement of -314:

+ +
11111111111111111111111011000110
+
+ +

The two's complement guarantees that the left-most bit is 0 when the number is positive and 1 when the number is negative. Thus, it is called the sign bit.

+ +

The number 0 is the integer that is composed completely of 0 bits.

+ +
0 (base 10) = 00000000000000000000000000000000 (base 2)
+
+ +

The number -1 is the integer that is composed completely of 1 bits.

+ +
-1 (base 10) = 11111111111111111111111111111111 (base 2)
+
+ +

The number -2147483648 (hexadecimal representation: -0x80000000) is the integer that is composed completely of 0 bits except the first (left-most) one.

+ +
-2147483648 (base 10) = 10000000000000000000000000000000 (base 2)
+
+ +

The number 2147483647 (hexadecimal representation: 0x7fffffff) is the integer that is composed completely of 1 bits except the first (left-most) one.

+ +
2147483647 (base 10) = 01111111111111111111111111111111 (base 2)
+
+ +

The numbers -2147483648 and 2147483647 are the minimum and the maximum integers representable through a 32bit signed number.

+ +

Bitwise logical operators

+ +

Conceptually, the bitwise logical operators work as follows:

+ + + +

& (Bitwise AND)

+ +

Performs the AND operation on each pair of bits. a AND b yields 1 only if both a and b are 1. The truth table for the AND operation is:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
aba AND b
000
010
100
111
+ +
.    9 (base 10) = 00000000000000000000000000001001 (base 2)
+    14 (base 10) = 00000000000000000000000000001110 (base 2)
+                   --------------------------------
+14 & 9 (base 10) = 00000000000000000000000000001000 (base 2) = 8 (base 10)
+
+ +

Bitwise ANDing any number x with 0 yields 0. Bitwise ANDing any number x with -1 yields x.

+ +

| (Bitwise OR)

+ +

Performs the OR operation on each pair of bits. a OR b yields 1 if either a or b is 1. The truth table for the OR operation is:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
aba OR b
000
011
101
111
+ +
.    9 (base 10) = 00000000000000000000000000001001 (base 2)
+    14 (base 10) = 00000000000000000000000000001110 (base 2)
+                   --------------------------------
+14 | 9 (base 10) = 00000000000000000000000000001111 (base 2) = 15 (base 10)
+
+ +

Bitwise ORing any number x with 0 yields x. Bitwise ORing any number x with -1 yields -1.

+ +

^ (Bitwise XOR)

+ +

Performs the XOR operation on each pair of bits. a XOR b yields 1 if a and b are different. The truth table for the XOR operation is:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
aba XOR b
000
011
101
110
+ +
.    9 (base 10) = 00000000000000000000000000001001 (base 2)
+    14 (base 10) = 00000000000000000000000000001110 (base 2)
+                   --------------------------------
+14 ^ 9 (base 10) = 00000000000000000000000000000111 (base 2) = 7 (base 10)
+
+ +

Bitwise XORing any number x with 0 yields x. Bitwise XORing any number x with -1 yields ~x.

+ +

~ (Bitwise NOT)

+ +

Performs the NOT operator on each bit. NOT a yields the inverted value (a.k.a. one's complement) of a. The truth table for the NOT operation is:

+ + + + + + + + + + + + + + + + +
aNOT a
01
10
+ +
 9 (base 10) = 00000000000000000000000000001001 (base 2)
+               --------------------------------
+~9 (base 10) = 11111111111111111111111111110110 (base 2) = -10 (base 10)
+
+ +

Bitwise NOTing any number x yields -(x + 1). For example, ~-5 yields 4.

+ +

Example with indexOf:

+ +
var str = 'rawr';
+var searchFor = 'a';
+
+// this is alternative way of typing if (-1*str.indexOf('a') <= 0)
+if (~str.indexOf(searchFor)) {
+  // searchFor is in the string
+} else {
+  // searchFor is not in the string
+}
+
+// here are the values returned by (~str.indexOf(searchFor))
+// r == -1
+// a == -2
+// w == -3
+
+ +

Bitwise shift operators

+ +

The bitwise shift operators take two operands: the first is a quantity to be shifted, and the second specifies the number of bit positions by which the first operand is to be shifted. The direction of the shift operation is controlled by the operator used.

+ +

Shift operators convert their operands to 32-bit integers in big-endian order and return a result of the same type as the left operand. The right operand should be less than 32, but if not only the low five bits will be used.

+ +

<< (Left shift)

+ +

This operator shifts the first operand the specified number of bits to the left. Excess bits shifted off to the left are discarded. Zero bits are shifted in from the right.

+ +

For example, 9 << 2 yields 36:

+ +
.    9 (base 10): 00000000000000000000000000001001 (base 2)
+                  --------------------------------
+9 << 2 (base 10): 00000000000000000000000000100100 (base 2) = 36 (base 10)
+
+ +

Bitwise shifting any number x to the left by y bits yields x * 2^y.

+ +

>> (Sign-propagating right shift)

+ +

This operator shifts the first operand the specified number of bits to the right. Excess bits shifted off to the right are discarded. Copies of the leftmost bit are shifted in from the left. Since the new leftmost bit has the same value as the previous leftmost bit, the sign bit (the leftmost bit) does not change. Hence the name "sign-propagating".

+ +

For example, 9 >> 2 yields 2:

+ +
.    9 (base 10): 00000000000000000000000000001001 (base 2)
+                  --------------------------------
+9 >> 2 (base 10): 00000000000000000000000000000010 (base 2) = 2 (base 10)
+
+ +

Likewise, -9 >> 2 yields -3, because the sign is preserved:

+ +
.    -9 (base 10): 11111111111111111111111111110111 (base 2)
+                   --------------------------------
+-9 >> 2 (base 10): 11111111111111111111111111111101 (base 2) = -3 (base 10)
+
+ +

>>> (Zero-fill right shift)

+ +

This operator shifts the first operand the specified number of bits to the right. Excess bits shifted off to the right are discarded. Zero bits are shifted in from the left. The sign bit becomes 0, so the result is always non-negative.

+ +

For non-negative numbers, zero-fill right shift and sign-propagating right shift yield the same result. For example, 9 >>> 2 yields 2, the same as 9 >> 2:

+ +
.     9 (base 10): 00000000000000000000000000001001 (base 2)
+                   --------------------------------
+9 >>> 2 (base 10): 00000000000000000000000000000010 (base 2) = 2 (base 10)
+
+ +

However, this is not the case for negative numbers. For example, -9 >>> 2 yields 1073741821, which is different than -9 >> 2 (which yields -3):

+ +
.     -9 (base 10): 11111111111111111111111111110111 (base 2)
+                    --------------------------------
+-9 >>> 2 (base 10): 00111111111111111111111111111101 (base 2) = 1073741821 (base 10)
+
+ +

Examples

+ +

Flags and bitmasks

+ +

The bitwise logical operators are often used to create, manipulate, and read sequences of flags, which are like binary variables. Variables could be used instead of these sequences, but binary flags take much less memory (by a factor of 32).

+ +

Suppose there are 4 flags:

+ + + +

These flags are represented by a sequence of bits: DCBA. When a flag is set, it has a value of 1. When a flag is cleared, it has a value of 0. Suppose a variable flags has the binary value 0101:

+ +
var flags = 5;   // binary 0101
+
+ +

This value indicates:

+ + + +

Since bitwise operators are 32-bit, 0101 is actually 00000000000000000000000000000101, but the preceding zeroes can be neglected since they contain no meaningful information.

+ +

A bitmask is a sequence of bits that can manipulate and/or read flags. Typically, a "primitive" bitmask for each flag is defined:

+ +
var FLAG_A = 1; // 0001
+var FLAG_B = 2; // 0010
+var FLAG_C = 4; // 0100
+var FLAG_D = 8; // 1000
+
+ +

New bitmasks can be created by using the bitwise logical operators on these primitive bitmasks. For example, the bitmask 1011 can be created by ORing FLAG_A, FLAG_B, and FLAG_D:

+ +
var mask = FLAG_A | FLAG_B | FLAG_D; // 0001 | 0010 | 1000 => 1011
+
+ +

Individual flag values can be extracted by ANDing them with a bitmask, where each bit with the value of one will "extract" the corresponding flag. The bitmask masks out the non-relevant flags by ANDing with zeroes (hence the term "bitmask"). For example, the bitmask 0100 can be used to see if flag C is set:

+ +
// if we own a cat
+if (flags & FLAG_C) { // 0101 & 0100 => 0100 => true
+   // do stuff
+}
+
+ +

A bitmask with multiple set flags acts like an "either/or". For example, the following two are equivalent:

+ +
// if we own a bat or we own a cat
+// (0101 & 0010) || (0101 & 0100) => 0000 || 0100 => true
+if ((flags & FLAG_B) || (flags & FLAG_C)) {
+   // do stuff
+}
+
+ +
// if we own a bat or cat
+var mask = FLAG_B | FLAG_C; // 0010 | 0100 => 0110
+if (flags & mask) { // 0101 & 0110 => 0100 => true
+   // do stuff
+}
+
+ +

Flags can be set by ORing them with a bitmask, where each bit with the value one will set the corresponding flag, if that flag isn't already set. For example, the bitmask 1100 can be used to set flags C and D:

+ +
// yes, we own a cat and a duck
+var mask = FLAG_C | FLAG_D; // 0100 | 1000 => 1100
+flags |= mask;   // 0101 | 1100 => 1101
+
+ +

Flags can be cleared by ANDing them with a bitmask, where each bit with the value zero will clear the corresponding flag, if it isn't already cleared. This bitmask can be created by NOTing primitive bitmasks. For example, the bitmask 1010 can be used to clear flags A and C:

+ +
// no, we don't have an ant problem or own a cat
+var mask = ~(FLAG_A | FLAG_C); // ~0101 => 1010
+flags &= mask;   // 1101 & 1010 => 1000
+
+ +

The mask could also have been created with ~FLAG_A & ~FLAG_C (De Morgan's law):

+ +
// no, we don't have an ant problem, and we don't own a cat
+var mask = ~FLAG_A & ~FLAG_C;
+flags &= mask;   // 1101 & 1010 => 1000
+
+ +

Flags can be toggled by XORing them with a bitmask, where each bit with the value one will toggle the corresponding flag. For example, the bitmask 0110 can be used to toggle flags B and C:

+ +
// if we didn't have a bat, we have one now,
+// and if we did have one, bye-bye bat
+// same thing for cats
+var mask = FLAG_B | FLAG_C;
+flags = flags ^ mask;   // 1100 ^ 0110 => 1010
+
+ +

Finally, the flags can all be flipped with the NOT operator:

+ +
// entering parallel universe...
+flags = ~flags;    // ~1010 => 0101
+
+ +

Conversion snippets

+ +

Convert a binary String to a decimal Number:

+ +
var sBinString = '1011';
+var nMyNumber = parseInt(sBinString, 2);
+alert(nMyNumber); // prints 11, i.e. 1011
+
+ +

Convert a decimal Number to a binary String:

+ +
var nMyNumber = 11;
+var sBinString = nMyNumber.toString(2);
+alert(sBinString); // prints 1011, i.e. 11
+
+ +

Automate Mask Creation

+ +

You can create multiple masks from a set of Boolean values, like this:

+ +
function createMask() {
+  var nMask = 0, nFlag = 0, nLen = arguments.length > 32 ? 32 : arguments.length;
+  for (nFlag; nFlag < nLen; nMask |= arguments[nFlag] << nFlag++);
+  return nMask;
+}
+var mask1 = createMask(true, true, false, true); // 11, i.e.: 1011
+var mask2 = createMask(false, false, true); // 4, i.e.: 0100
+var mask3 = createMask(true); // 1, i.e.: 0001
+// etc.
+
+alert(mask1); // prints 11, i.e.: 1011
+
+ +

Reverse algorithm: an array of booleans from a mask

+ +

If you want to create an Array of Booleans from a mask you can use this code:

+ +
function arrayFromMask(nMask) {
+  // nMask must be between -2147483648 and 2147483647
+  if (nMask > 0x7fffffff || nMask < -0x80000000) {
+    throw new TypeError('arrayFromMask - out of range');
+  }
+  for (var nShifted = nMask, aFromMask = []; nShifted;
+       aFromMask.push(Boolean(nShifted & 1)), nShifted >>>= 1);
+  return aFromMask;
+}
+
+var array1 = arrayFromMask(11);
+var array2 = arrayFromMask(4);
+var array3 = arrayFromMask(1);
+
+alert('[' + array1.join(', ') + ']');
+// prints "[true, true, false, true]", i.e.: 11, i.e.: 1011
+
+ +

You can test both algorithms at the same time…

+ +
var nTest = 19; // our custom mask
+var nResult = createMask.apply(this, arrayFromMask(nTest));
+
+alert(nResult); // 19
+
+ +

For didactic purpose only (since there is the Number.toString(2) method), we show how it is possible to modify the arrayFromMask algorithm in order to create a String containing the binary representation of a Number, rather than an Array of Booleans:

+ +
function createBinaryString(nMask) {
+  // nMask must be between -2147483648 and 2147483647
+  for (var nFlag = 0, nShifted = nMask, sMask = ''; nFlag < 32;
+       nFlag++, sMask += String(nShifted >>> 31), nShifted <<= 1);
+  return sMask;
+}
+
+var string1 = createBinaryString(11);
+var string2 = createBinaryString(4);
+var string3 = createBinaryString(1);
+
+alert(string1);
+// prints 00000000000000000000000000001011, i.e. 11
+
+ +

Specifications

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('ES1')}}{{Spec2('ES1')}}Initial definition.
{{SpecName('ES5.1', '#sec-11.7')}}{{Spec2('ES5.1')}}Defined in several sections of the specification: Bitwise NOT operator, Bitwise shift operators, Binary bitwise operators
{{SpecName('ES6', '#sec-bitwise-shift-operators')}}{{Spec2('ES6')}}Defined in several sections of the specification: Bitwise NOT operator, Bitwise shift operators, Binary bitwise operators
{{SpecName('ESDraft', '#sec-bitwise-shift-operators')}}{{Spec2('ESDraft')}}Defined in several sections of the specification: Bitwise NOT operator, Bitwise shift operators, Binary bitwise operators
+ +

Browser compatibility

+ + + +

{{Compat("javascript.operators.bitwise")}}

+ +

See also

+ + diff --git a/files/tr/conflicting/web/javascript/reference/operators_603c79383d36dadbe5083df806de5999/index.html b/files/tr/conflicting/web/javascript/reference/operators_603c79383d36dadbe5083df806de5999/index.html new file mode 100644 index 0000000000..8a1e2ea56f --- /dev/null +++ b/files/tr/conflicting/web/javascript/reference/operators_603c79383d36dadbe5083df806de5999/index.html @@ -0,0 +1,312 @@ +--- +title: Mantıksal Operatörler +slug: Web/JavaScript/Reference/Operatörler/Mantiksal_Operatorler +tags: + - Değil + - JavaScript + - Mantıksal Operatörler + - Operator + - Referans + - ve + - ya da +translation_of: Web/JavaScript/Reference/Operators +translation_of_original: Web/JavaScript/Reference/Operators/Logical_Operators +--- +
{{jsSidebar("Operators")}}
+ +

Mantıksal operatörler genellikle {{jsxref("Boolean")}} (mantıksal) değerleri ile kullanılır. Kullanıldıklarında, bir boolean değer döndürürler. Ancak, && ve || operatörleri aslında belirtilmiş olan operandlardan birinin değerini döndürür, bu sebeple eğer bu operatörler Boolean olmayan değerler ile kullanılırsa, Boolean olmayan değerler üretebilirler.

+ +

Açıklama

+ +

Mantıksal operatörler aşağıdaki tabloda açıklanıyor:

+ + + + + + + + + + + + + + + + + + + + + + + + +
OperatörKullanımAçıklama
Mantıksal VE (&&)expr1 && expr2Eğer expr1 false değerine dönüştürülebilirse, expr1  döndürülür. Aksi halde, expr2 döndürülür. Böylece, Boolean değerleri ile kullanıldıklarında, && her iki operand true ise true ; aksi halde, false döndürür.
Mantıksal YA DA (||)expr1 || expr2Eğer expr1 true değerine dönüştürülebilirse, expr1 döndürülür, aksi halde, expr2 döndürülür. Böylece, Boolean değerleri ile kullanıldıklarında, || her iki operanddan herhangi biri true ise true döndürür.
Mantıksal DEĞİL (!)!exprEğer operandın değeri true is false döndürür, aksi alde true döndürür.
+ +

Eğer bir değer true değerine dönüştürülebiliyorsa, ona {{Glossary("truthy")}} ismi verilir. Eğer bir değer false değerine dönüştürülebiliyorsa, ona {{Glossary("falsy")}} denir.

+ +

False değerine dönüştürülebilen ifadelere örnekler:

+ + + +

&& ve || operatörleri Boolean olmayan değerler ile kullanılabiliyor olmasına rağmen, döndürdükleri değerler her zaman Boolean değerlerine çevirilebildiğinden, halen Boolean operatörleri olarak düşünülebilirler.

+ +

Kısa-devre değerlendirmeleri

+ +

Mantıksal operatörler soldan sağa çalıştırıldıkları gibi, mümkünse aşağıdaki kurallar kullanılarak "kısa devre" testine tabi tutulurlar:

+ + + +

Mantık kuralları bu değerlendirmelerin doğruluğunu garantiler. Yukarıdaki ifadelerin tümünün çalıştırılmayacağına, bu sebeple hepsinin yan etkisinin olmayacağına dikkat edin. Ayrıca yukarıdaki ifadenin (herhangi) kısmının tamamıyla bir mantıksal ifadeye eşit olduğuna dikkat edin. (parantezler ile gösterildiği gibi).

+ +

Örneğin, aşağıdaki iki fonksiyon birbirinin aynısıdır.

+ +
function shortCircuitEvaluation() {
+  doSomething() || doSomethingElse()
+}
+
+function equivalentEvaluation() {
+  var flag = doSomething();
+  if (!flag) {
+    doSomethingElse();
+  }
+}
+
+ +

Ancak, aşağıdaki ifadeler operatör önceliğine göre eşit değildir ve sağ el operatörünün tek bir ifade olmasının önemini vurgular (gerekirse parantezler ile gruplanır).

+ +
false && true  || true      // returns true
+false && (true || true)     // returns false
+ +

Mantıksal VE (&&)

+ +

Aşağıdaki kod && (mantıksal VE) operatörüyle ilgili örnekleri gösterir.

+ +
a1 = true  && true      // t && t returns true
+a2 = true  && false     // t && f returns false
+a3 = false && true      // f && t returns false
+a4 = false && (3 == 4)  // f && f returns false
+a5 = "Cat" && "Dog"     // t && t returns "Dog"
+a6 = false && "Cat"     // f && t returns false
+a7 = "Cat" && false     // t && f returns false
+a8 = "" && false        // returns ""
+a9 = false && ||        // returns false
+
+ +

Mantıksal YA DA (||)

+ +

Aşağıdaki kod || (mantıksal YA DA) operatörüyle ilgili örnekleri gösterir.

+ +
o1 = true  || true       // t || t returns true
+o2 = false || true       // f || t returns true
+o3 = true  || false      // t || f returns true
+o4 = false || (3 == 4)   // f || f returns false
+o5 = "Cat" || "Dog"      // t || t returns "Cat"
+o6 = false || "Cat"      // f || t returns "Cat"
+o7 = "Cat" || false      // t || f returns "Cat"
+o8 = ""    || false      // returns false
+o9 = false || ""         // returns ""
+
+ +

Mantıksal DEĞİL (!)

+ +

Aşağıdaki kod ! (mantıksal DEĞİL) operatörüyle ilgili örnekleri gösterir.

+ +
n1 = !true              // !t returns false
+n2 = !false             // !f returns true
+n3 = !"Cat"             // !t returns false
+
+ +

Dönüşüm kuralları

+ +

VE operatörünü YA DA operatörüne dönüştürmek

+ +

Booleanları içeren aşağıdaki ifade:

+ +
bCondition1 && bCondition2
+ +

her zaman şuna eşittir:

+ +
!(!bCondition1 || !bCondition2)
+ +

YA DA operatörünü VE operatörüne çevirmek

+ +

Booleanları içeren aşağıdaki ifade:

+ +
bCondition1 || bCondition2
+ +

her zaman şuna eşittir:

+ +
!(!bCondition1 && !bCondition2)
+ +

DEĞİL operatörleri arasında dönüşüm yapmak

+ +

Booleanları içeren aşağıdaki ifade:

+ +
!!bCondition
+ +

her zaman şuna eşittir: 

+ +
bCondition
+ +

İç içe geçmiş parantezleri kaldırmak

+ +

Mantıksal operatörlerin soldan sağa değerlendirilmesi durumunda, kompleks bir ifadeden parantezleri bazı kuralları takip ederek kaldırmak mümkündür.

+ +

İç içe geçmiş VE operatörünü kaldırmak

+ +

Aşağıda, Boolean içeren bu bileşik işlem:

+ +
bCondition1 || (bCondition2 && bCondition3)
+ +

her zaman şuna eşittir:

+ +
bCondition1 || bCondition2 && bCondition3
+ +

İç içe geçmiş YA DA operatörünü kaldırmak

+ +

Aşağıda, Boolean içeren bu bileşik ifade:

+ +
bCondition1 && (bCondition2 || bCondition3)
+ +

her zaman şuna eşittir:

+ +
!(!bCondition1 || !bCondition2 && !bCondition3)
+ +

Özellikler

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ÖzellikDurumAçıklama
{{SpecName('ES1')}}{{Spec2('ES1')}}İlk tanım.
{{SpecName('ES5.1', '#sec-11.11')}}{{Spec2('ES5.1')}}Tarifnamenin birkaç bölümünde tanımlandı: Logical NOT Operator, Binary Logical Operators
{{SpecName('ES6', '#sec-binary-logical-operators')}}{{Spec2('ES6')}}Tarifnamenin birkaç bölümünde tanımlandı: Logical NOT Operator, Binary Logical Operators
{{SpecName('ESDraft', '#sec-binary-logical-operators')}}{{Spec2('ESDraft')}}Tarifnamenin birkaç bölümünde tanımlandı: Logical NOT Operator, Binary Logical Operators
+ +

Tarayıcı Uyumluluğu

+ +

{{CompatibilityTable}}

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Mantıksal VE (&&){{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
+

Mantıksal YA DA (||)

+
{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
Mantıksal DEĞİL (!){{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ÖzellikAndroidAndroid üzerinde ChromeFirefox Mobil (Gecko)IE MobilOpera MobilSafari Mobil
Logical AND (&&){{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
Logical OR (||){{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
Logical NOT (!){{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
+
+ +

Ayrıca bakın

+ + -- cgit v1.2.3-54-g00ecf