Skip to content

Instantly share code, notes, and snippets.

@aloerina01
Created June 28, 2016 12:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aloerina01/daae2245115da09b723dc59bd1b2b9b9 to your computer and use it in GitHub Desktop.
Save aloerina01/daae2245115da09b723dc59bd1b2b9b9 to your computer and use it in GitHub Desktop.
【失敗例】exports/requireの使い方
'use strict';
class ListView {
constructor() {
this.list = [];
};
add(item) {
this.list.push(item);
return this;
};
show() {
this.list.forEach(function(e){
console.log(e);
});
};
};
var ListView = require('./list-view');
function execute() {
var listView = new ListView();
listView.add('item1').add('item2').show();
}
execute(); // ListView is not a function となり、コンストラクタを呼べない
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment