在以下代码中,nonStatic()不是静态方法.即使这样,我也能够在不创建对象的情况下(以静态方式)访问它.任何人都可以帮助我理解,因为这在Java等其他语言中是不可能的吗?
<?php
class MyClass
{
function nonStatic() {
echo "This can be printed";
}
}
MyClass::nonStatic(); // This can be printed
Run Code Online (Sandbox Code Playgroud) 为什么下面的代码中map()输出有区别?
var y = [1,2,2,1];
var t = y.map(ind => [...Array(ind)].map((_,i) => ind+""+i));
// This makes [ [ '10' ], [ '20', '21' ], [ '20', '21' ], [ '10' ] ]
var t1 = y.map(ind => Array(ind).map((_,i) => ind+""+i));
//[ [ <1 empty item> ], [ <2 empty items> ], [ <2 empty items> ], [ <1 empty item> ] ]
Run Code Online (Sandbox Code Playgroud)