在你看来,你遇到过的最令人惊讶、最怪异、最奇怪或最“WTF”的语言特性是什么?
请每个回答只回答一个特征。
在你看来,你遇到过的最令人惊讶、最怪异、最奇怪或最“WTF”的语言特性是什么?
请每个回答只回答一个特征。
当前回答
在JavaScript中,undefined是一个全局变量,其默认值为原始值undefined。你可以改变undefined的值:
var a = {};
a.b === undefined; // true because property b is not set
undefined = 42;
a.b === undefined; // false
由于undefined的可变性,通过typeof检查undefined通常是一个更好的主意:
var a = {};
typeof a.b == "undefined"; // always true
其他回答
在流行性腮腺炎中,你可以有一个带偏移的GOTO。如果你有(我的腮腺炎已经生锈了…)
some_label if x=1 do_something
else do_something_else
然后是代码
goto some_label+1
将跳转到ELSE语句…
通知7。一个有效程序的例子:
Chomsky is a room. A thought is a kind of thing. Color is a kind of value. The colors are red, green and blue. A thought has a color. It is usually Green. A thought can be colorful or colorless. It is usually colorless. An idea is a thought in Chomsky with description "Colorless green ideas sleep furiously." A manner is a kind of thing. Furiously is a manner. Sleeping relates one thought to one manner. The verb to sleep (he sleeps, they sleep, he slept, it is slept, he is sleeping) implies the sleeping relation. Colorless green ideas sleep furiously.
像图灵机模拟器这样的其他愚蠢的东西可以找到。
一般来说,弱类型。
C:
printf("%c\n", 'a' + 3);
PHP:
echo 5 + "3";
还有太多其他语言。
在JavaScript中,2.0 - 1.1 = 0.8999999999999999。这是规范中实现浮点数的结果,所以它总是这样的。
在C中,a[b][C]与C [b[a]]完全相同。