严格模式为什么不对重复的属性名称抛出语法错误?

时间:2019-06-18 21:22:01

标签: javascript strict-mode

在JavaScript中,如果我们尝试定义具有重复属性的对象,则严格模式应该引发语法错误,例如:

for img_file in os.listdir(img_dir):
    if img_file.endswith(".jpg"):
        texts = str(((pytesseract.image_to_string(Image.open(img_file)))))
        print(texts)
        file = img_file[:-4] + ".txt"
        #create the new file with "w+" as open it
        with open(file, "w+") as f:
            f.write(texts)
            print(file) 

叫我疯了,但我记得确实如此。今天,我很震惊地发现它至少没有在macOS上的最新Chrome和Firefox中出现。

const foo = {a: 1, a: 2};

发生了什么事?

0 个答案:

没有答案