0415 劉旻杰
dvi id="cat">
<DVI ID='cat'></DVI>
<SCRIPT>
dict =new Map([["2303","聯電"],["2330","台積電"],["2880","華南金"]]);//宣告配對(字典)
class Stock{ //宣告類別
constructor(code, shares, price){
this.code = code;
this.shares = shares;
this.price = price;}
}
s1 = new Stock("2330", 100, 1000); //建構子Stock建構s1
s2 = new Stock("2880", 10000, 30); //建構子Stock建構s2
st = s1.code+' 股數 '+s1.shares.toString()+'<BR>'+s2.code.toString()+' 股數 '+s2.shares;
document.getElementById('cat').innerHTML = st;
</SCRIPT>
415.https://jamie941128.blogspot.com/2025/04/0415.html
回覆刪除