メンドイのでSpidermonkeyで実行。

#!/usr/bin/env js                                                             

var human = function() {
var that = {}
that.say = function() {
print('Hello!')
return that
}
return that
}

var employee = function() {
var that = human()
that.has_work = true
return that
}

var neet = function() {
var that = human()
that.has_work = false
that.say = function() {
print('絶対に働きたくないでござる!')
return that
}
return that
}

human().say()
employee().say()
neet().say()
Hello!
Hello!
絶対に働きたくないでござる!

簡単。

JavaScript: The Good Parts ―「良いパーツ」によるベストプラクティス

Comments


Option