为什么没有为函数创建引用f
if ( function f() { } ) {
console.log( typeof f );
}
// result: undefined Run Code Online (Sandbox Code Playgroud)
而分配/设置变量正常工作内if( )
if ( f = 'assigned' ) {
console.log( typeof f );
}
// result: stringRun Code Online (Sandbox Code Playgroud)
我需要知道在第一种情况下会发生什么,因为第二种情况正如预期的那样工作
有人可以解释一下吗?
我无法理解为什么在这个程序2 - 4给出-1,它已经为指针而不是地址分配了int值,我知道但是当我编译它时编译器给出了一些警告,但编译了程序并执行但是...
程序
#include<stdio.h>
int main(void) {
int *p, *q;
int arr[] = {1,2,3,4};
// I know p and q are pointers and address should be assigned to them
// but look at output, why it evaluates (p-q) to -1 while p as 2 and q as 4
p = arr[1];
q = arr[3];
printf("P-Q: %d, P: %d, Q: %d", (p - q), p, q);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
它给
P-Q: -1, P: 2, Q: 4
Run Code Online (Sandbox Code Playgroud)