export

JavaScript 1.2+, ECMAScript 1.0+ Nav4+ Syntax

export

Description

Export is a keyword used by scripts implementing security features that makes objects, properties, and methods accessible to other unsigned scripts.

Example

Listing 6.120 shows how to use the export keyword. In the JavaScript code, the export keyword is used to make the variables, name, city, and function, showName() available to other unsigned scripts. Other scripts would access the information using the import keyword.

Listing 6.120 Example of Using export
 <html> <body> <script language = "JavaScript"> <!–– Hide // declare variables var name = "John Smith"; var city = "Atlanta"; function showName(){ alert("Your name is: " + name); } // makes two variables and ...

Get Pure JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.