String.prototype.split()返回一个奇怪的数组对象

时间:2017-05-15 09:21:14

标签: javascript arrays

我想知道由empty构建的"".split("\n")的价值是什么。
这是我找到它的试验。



var empty = "";
empty = empty.split("\n");
console.log("Is empty's length one? ")
console.log(empty.length === 1);
console.log("------");
console.log("Is empty's first value is a empty string (\"\")? ");
console.log(empty[0] === "");
console.log("------");
console.log("Then what is the constructor of empty? ");
console.log(empty.constructor.name);
console.log("------");
console.log("Is empty === [\"\"]? ");
console.log(empty === [""]);
console.log("------");
console.log("Is empty == [\"\"]? ");
console.log(empty == [""]);
console.log("------");
console.log("Then what is empty? ");
console.log(empty);




如您所见,空的长度为1,其值为空字符串 问题是,为什么它不等于[""],它的价值是多少?

0 个答案:

没有答案