Webpack已安装Babel,Terser(JavaScript缩小程序)和压缩插件。当我查看输出代码时,它看起来像char[] guessed = new char[26];
char guess;
char playAgain;
int amountMissed = 0,index = 0;
do
{
char[] word = RandomLine().ToCharArray(); // Change :This needs to be inside the loop so that new random word could be selected user selects to continue the game
char[] testword = new string('*',word.Length).ToCharArray(); // Change : Reordered initilization of word and testword so that we could generate testword with same length as original
char[] copy = word;
Console.WriteLine(testword);
Console.WriteLine("I have picked a random word on animals");
Console.WriteLine("Your task is to guess the correct word");
while (!testword.SequenceEqual(word)) // Change : Comparison of arrays
{
Console.Write("Please enter a letter to guess: ");
guess = char.Parse(Console.ReadLine());
bool right = false;
for (int j = 0; j < copy.Length; j++)
{
if (copy[j] == guess)
{
Console.WriteLine("Your guess is correct.");
testword[j] = guess;
guessed[index] = guess;
index++;
right = true;
}
}
if (right != true)
{
Console.WriteLine("Your guess is incorrect.");
amountMissed++;
}
else
{
right = false;
}
Console.WriteLine(testword);
}
Console.WriteLine($"The word is {copy}. You missed {amountMissed} times.");
Console.WriteLine("Do you want to guess another word? Enter y or n: ");
playAgain = char.Parse(Console.ReadLine());
} while (playAgain == 'y' || playAgain == 'Y');
Console.WriteLine("Good-Bye and thanks for playing my Hangman game.");
。在应用return null == n?"":Object(rO)(n)
函数之后,有一些代码调用了该函数。
此外,由于使用了ES模块,因此Babel的模块转换将停止,并且Webpack将直接处理导入/导出。
问题
- 因此,为什么
Object
包含在导入结果中? -
在像
Object()
这样的Object()
的结果上调用函数时,如果忽略覆盖对象本身的情况,则在有或没有Object(foo)(bar)
的情况下都会调用同一函数,如果它不是一个函数,则无论是否带有Object()
都将是TypeError,因此即使删除Object()
,行为也没有明显的不同。那不正确吗? -
如果在函数调用之前删除
Object()
不会导致行为上的严重差异(如果根本没有差异,或者没有问题,请考虑差异仅在于边缘情况,并且它正在处理导入),我想删除此Object()
以减少输出容量。我在Webpack中要删除此配置是什么?
- Webpack 4.29.6
- babel-loader 8.0.5
- @ babel / core 7.3.4
- terser-webpack-plugin 1.2.3
- terser 3.16.1
- compression-webpack-plugin 2.0.0