Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
qiilee opened this issue Apr 15, 2020 · 1 comment
Open

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

qiilee opened this issue Apr 15, 2020 · 1 comment

Comments

@qiilee
Copy link
Member

qiilee commented Apr 15, 2020

// 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的名称及其对应的值

@xuanwochutian
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants