In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "how to use export and as in es6". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
In es6, the export keyword is used to modularize variables, functions, and objects for external reference and to provide an external calling interface with the syntax "export var a = 'name';"; the as keyword is used to modify the variable name and the syntax is "export {new variable name as old variable name}".
This tutorial operating environment: windows10 system, ECMAScript version 6. 0, Dell G3 computer.
The usage of export and as in es6
The usage of export:
Export allows us to modularize variables, functions, and objects, providing an external calling interface for external references. Let's start with the simplest example of modularizing a variable. Let's create a new temp.js file and output a module variable in the file.
Export var a = 'jspang'
It can then be introduced in the form of import in index.js.
Import {a} from'. / temp.js';console.log (a)
Cmd command module input
Babel-node index.js should pay attention to the catalogue
Multivariable output (temp.js)
Var a = 'jspang';var b =' technical fat'; var c = 'web';export {a dint bjournal c} / / wrapped as an object {}
Modular output of the function (temp.js)
Export function add (aformab) {return aforb;}
The usage of as
Sometimes we don't want to expose the variable name in the module, but give the module a more semantic name, so we can use as to operate.
Var a = 'jspang';var b =' technical fat'; var c = 'web';export {x as a, y as b, z as c}
When you may encounter a variable name duplicate or need to change a variable name during development, you can rename it with the keyword as in ES6.
This is the end of the content of "how to use export and as in es6". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.