Skip to content

Instantly share code, notes, and snippets.

View shikumiya-hata's full-sized avatar

エンドウ ユウジ(Yuji ENDO) shikumiya-hata

View GitHub Profile
class Foo {
constructor() {
this._va = 0
}
}
/**
* Fooクラスを取得する
* @return {Foo} - Fooクラス
*/
class Foo {
constructor() {
}
}
function foo() { return Foo } // クラスを取得する
const foo = Lib.foo() // 「Foo#constructor()」が出力される
foo.hoge() // 「Foo#hoge()」が出力される
class Foo {
constructor() {
console.log('Foo#constructor()')
}
hoge() {
console.log('Foo#hoge()')
return true
}
}
const Foo = Lib.foo() // クラスをlocal globalな定数に入れてしまう
function myFunction() {
const foo = new Foo() // 「Foo#constructor()」が出力される
foo.hoge() // 「Foo#hoge()」が出力される
}
function myFunction() {
const foo = new (Lib.foo())() // 「Foo#constructor()」が出力される
foo.hoge() // 「Foo#hoge()」が出力される
}
class Foo {
constructor() {
console.log('Foo#constructor()')
}
hoge() {
console.log('Foo#hoge()')
return true
}
}
function myFunction() {
const foo = new Lib.foo() // 「Foo#constructor()」が出力される
foo.hoge() // 「Foo#hoge()」が出力される
}
class Foo {
constructor() {
console.log('Foo#constructor()')
}
hoge() {
console.log('Foo#hoge()')
return true
}
}
function test() {
console.log(this.a) // 1
console.log(this.b) // 2
console.log(this.c) // undefined
console.log(this.d) // undefined
console.log(this.e()) // 5
console.log(a) // 1
console.log(b) // 2
console.log(c) // 3