GTM 中的字符串 > 0。如何?
String > 0 in GTM. How?
在 Google 跟踪代码管理器中有一个非常简单的示例,其中包含数据类型。我有 2 个变量 '- 5'
和 '6'
5 + 6 string = 56
,对!
但是当我return一个条件字符串为56 > 0 数字的布尔值时,它怎么写成true?
一个数字字符串通常会 coerced 到一个数字进行数学运算和比较,但也有例外,例如 +
运算。参见@Eike 的示例:
the "+" sign is an exception in that it does not trigger an implicit type conversion when one of the operands is a string. Other mathematical operators do implicit type conversion. So "5" + "6"
is "56"
, but "56" > 0
is converted into 56 > 0
, which evaluates to true
.
console.log("5" * "6"); // coerce
console.log("5" < "6"); // coerce
console.log("5" + "6"); // no coercion
在 Google 跟踪代码管理器中有一个非常简单的示例,其中包含数据类型。我有 2 个变量 '- 5'
和 '6'
5 + 6 string = 56
,对!
但是当我return一个条件字符串为56 > 0 数字的布尔值时,它怎么写成true?
一个数字字符串通常会 coerced 到一个数字进行数学运算和比较,但也有例外,例如 +
运算。参见@Eike 的示例:
the "+" sign is an exception in that it does not trigger an implicit type conversion when one of the operands is a string. Other mathematical operators do implicit type conversion. So
"5" + "6"
is"56"
, but"56" > 0
is converted into56 > 0
, which evaluates totrue
.
console.log("5" * "6"); // coerce
console.log("5" < "6"); // coerce
console.log("5" + "6"); // no coercion