web-interview icon indicating copy to clipboard operation
web-interview copied to clipboard

[选择题] 62.(单选题)输出什么?

Open qiilee opened this issue 5 years ago • 1 comments

// module.js
export default () => 'Hello world'
export const name s 'Lydia'
// index.js
import * as data from './module'
console.log(data)
A:{ default: function default(), name: "Lydia"}  
B: { default: function default() }
C: { default: "Hello world", name: "Lydia"}
D: Global object of module.js 

答案:A

解析:

使用import * as name语法,我们将module.js文件中所有export导入到index, js文件中,并且创建了一个名为data的新对象。在module.js文件中,有两个导出:默认导出和命名导出,默认导出是一个返回字符串'Hello world'的函数,命名导出是一个名为name的变量,其值为字符串 'Lydia'。

data对象具有默认导出的default属性,其他属性具有指定exports的名称及其对应的值

qiilee avatar Apr 15 '20 11:04 qiilee

const name s 'Lydia' 这个s是什么写法

xuanwochutian avatar Jan 10 '24 07:01 xuanwochutian