这是我唯一的JavaScript代码。
#include "stdafx.h"
#include "AI0.h"
#include "InterfaceLayer.h"
#include <algorithm>
#include <chrono>
AI0::AI0()
{
Searching = ATOMIC_VAR_INIT(false);
SearchThread = nullptr;
InfoThread = nullptr;
}
void AI0::Ponder(Game game, U8 depth)
{
SearchThread = new std::thread(&AI0::search, this, game.GetState());
InfoThread = new std::thread(&AI0::SendInfo, this);
SearchThread->detach();
InfoThread->detach();
}
void AI0::StopPondering()
{
Searching.store(false);
}
void AI0::search(GameState state)
{
while (Searching.load())
{
//Search code.
//Sets some global data which I do see correctly on main thread.
}
}
void AI0::SendInfo()
{
while (Searching.load())
{
//Code to update interface layer about search progress.
std::this_thread::sleep_for(std::chrono::seconds(1));
}
}
功能块内的console.log按预期打印“Joby”。
外部控制台正在控制台中打印。我期待外部控制台声明的“引用错误”。为什么会那样?
我正在使用Google Chrome浏览器。 firefox中显示了相同的输出。
答案 0 :(得分:6)
name
是key/property
window
个name(global variable)
对象,IIFE
引用的name
变量指的是window
window
}
Window.name
,获取/设置(function() { var name = "Joby"; console.log(name); })(); console.log(name); console.log('---With some other variable name---'); (function() { var name1 = "Joby"; console.log(name1); })(); console.log(name1);//you can find `ReferenceError` here!
的名称
12:02:39 PM Executing tasks: [:app:clean, :app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies, :app:assembleDebug]
12:03:58 PM Gradle build finished with 1440 error(s) in 1m 18s 260ms