工廠模式是一種多重重複性的設計模式
有許多不同建構工廠模式的方法,這篇就先筆記其中一種方法
(另外一種參考資料中的 [5] [6] 裡有)
function obj(){
this.val='Hello';
}
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"