如何使用带有"Add“方法的类将这个简单的javascript转换为正确的类型记录语法?
var i, rec;
var myArray = [];
for (i = 0; i < 10; i++) {
rec = { name: "john", age: i };
myArray.push(rec);
}
我知道了如何至少定义一个变量,但我不能使用"Add“方法来加载它:
var myArray: { name: string; age: number }[] = [];
下面是我在类中使用Add方法的可悲尝试:
class MyClas
所以现在有两件事我被困住了。第一
class DisplayTaxonomy {
public $MyArray[]= new DisplayTaxonomy(); //the compiler says syntax error
//things I have tried
//public $ss[]= new Object();
}
第二!在下面这样的函数中:
public function whatever()
{
$Temp = new DisplayTaxonomy();
$Temp->setADTitle("1");
我发现Array对象和Array.prototype都具有length属性。我对使用Array.length属性感到困惑。你是怎么用的?
Console.log(Object.getOwnpropertyNames(Array));//As per Internet Explorer
产出:
length,arguments,caller,prototype,isArray,
Prototype和isArray是可用的,但是如何使用length属性?
我正在使用ECMAScript6实现一个客户端应用程序,并使用进行静态代码分析。我经常在代码中使用以下模式:
class MyClass {
constructor() {
//This is how I would like to call myMethod
myMethod();
//This is how I should call myMethod to make JSHint analysis pass
this.myMethod();
}
myMethod(){
//Imp