zumafra
zumafra

Reputation: 1323

JavaScript module keyword

I'm working through Kyle Simpson's "You Don't Know JavaScript" series. At the end of (published 2014) "Scope & Closures" (p. 62), there is an example in ES6 of using the keyword "module" to import an entire module, like so:

// import the entire "foo" and "bar" modules
module foo from "foo";
module bar from "bar";

console.log(
    bar.hello( "rhino" )    
); 

foo.awesome();

This code doesn't work, however. My question is: is the module keyword something that was experimented with and dropped? Should I forget about this keyword?

Upvotes: 8

Views: 2403

Answers (1)

Tu Nguyen
Tu Nguyen

Reputation: 10179

They're typos

// import the entire "foo" and "bar" modules
import foo from "foo";  //fixed
import bar from "bar";  //fixed

console.log(
    bar.hello( "rhino" )    
); 

foo.awesome();

Sometimes, the examples in a book are not 100% accurate in typo, they really make confusion for the beginners.

Upvotes: 5

Related Questions