小编Shi*_*kur的帖子

类的静态和实例方面的区别

当我遇到类类型时,我试图理解Typescript中的界面主题,我从官方文档中获取此代码

interface ClockConstructor {
    new (hour: number, minute: number);
}

class Clock implements ClockConstructor {
    currentTime: Date;
    constructor(h: number, m: number) { }
}
Run Code Online (Sandbox Code Playgroud)

我可以理解,这Clock与签名无法匹配, new (hour: number, minute: number);这就是我们在那里得到错误的原因.

但在文档中,解释是我无法理解的.它是这样的:

这是因为当类实现接口时,只检查类的实例端.由于构造函数位于静态方面,因此它不包含在此检查中.

任何解释将不胜感激.

javascript typescript

14
推荐指数
2
解决办法
1460
查看次数

在setTimeout完成执行后调用函数-Javascript

我有一个场景,我想在执行三个函数a(),b(),c()之后调用函数d(),这三个函数并行执行.

setTimeout(function a(){ alert("Hello A"); a()}, 3000);
setTimeout(function b(){ alert("Hello B"); b()}, 3000);
setTimeout(function c(){ alert("Hello C"); c()}, 3000);
Run Code Online (Sandbox Code Playgroud)

在完成所有函数执行后,我希望执行下面的函数d()

function d(){
console.log('hello D')
}
Run Code Online (Sandbox Code Playgroud)

任何帮助,将不胜感激.

javascript jquery

3
推荐指数
1
解决办法
725
查看次数

了解express的app.mountpath属性

我是新手来表达框架并尝试学习基础知识,但我不了解快递js的app.mountpath属性.

我已经完成了文档,但仍然非常困惑.

任何解释都表示赞赏

node.js express

2
推荐指数
1
解决办法
1159
查看次数

错误:分段错误(代码转储)

我是数据结构的新手,并从链表开始,我试图在链表的末尾添加元素,但得到错误分段错误.我用C语言实现它.

我不明白这个错误意味着什么

码:

struct node 
{
int data;
struct node *next;
};
struct node *head;
void fnInsert(int x){
    if(head==NULL){
    printf("head is null");
    node* temp=(node*)malloc(sizeof(struct node));
    temp->data=x;
    temp->next=head;
    head=temp;
    }
    else{
        node* temp=head;
        struct node* previousNode;
        do{
            temp=temp->next;
            previousNode=temp;
        }while(temp!=NULL);
        node* temp1=(node*)malloc(sizeof(struct node));
            temp1->data=x;
            previousNode->next=temp1;
            temp1->next=NULL;
    }
};
void fnPrint(){
   struct node* temp=head;
   printf("list is:\n");
   while(temp!=NULL){
       printf("%d",temp->data);
       temp=temp->next;
       printf("\n");
   }
}
int main(){
    head=NULL;
    printf("how many numbers\n");
    int n,i,x;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        printf("Enter the number\n");
        scanf("%d",&x);
        fnInsert(x);
        fnPrint();
    }
}
Run Code Online (Sandbox Code Playgroud)

任何帮助,将不胜感激.

c data-structures

0
推荐指数
1
解决办法
111
查看次数

标签 统计

javascript ×2

c ×1

data-structures ×1

express ×1

jquery ×1

node.js ×1

typescript ×1