王鈺嘉JavaScript物件CANV

複製甲班示範

w3schools學物件

<style>
.a{background-image: linear-gradient(red, yellow); font-size: 32px; line-height:1.5}
.b{background-image: linear-gradient(red, blue); color: white; font-size:30px}
</style>
identifier名稱,身分證id card
<p id="xyz" class="a"></p>
<p id="dog" class="b"></p>
<p id="cat" class="a"></p>
<script>
// Create an object:
const band = {
guitar:"侯麗鷗", 
vocals:"蔡依雯",
bass:"林志玲"};
delete band.vocals;
band["singer"] = "王鈺嘉";
s=""; //定義變數空白
document.getElementById("xyz").innerHTML = Object.keys(band);
document.getElementById("dog").innerHTML = Object.values(band);
for (job in band){ 
   s+= job + "手: " + band[job] + "<br>"};
document.getElementById("cat").innerHTML = s;
</script>
<H1>w3schools學物件</H1>
<div class="separator" style="clear: both;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEho4JiGSnOa-XJIMRWEI9Iffico8LsUaEO7b_Ijdnzz_Aw2sjVGFR-jlJ8pOkmpwyfY7t0wIvF5oszqzW9f3NwJh37Bg1So7hfTotNFpvBKi4D70Y3OgrT7fY8F9wVVbTvMn-FKuVDE0vXrmDEWMYMnhqfQPg8xLbs0g7r7y2LDHDX2MywwnLFv0LP6ZLc/s1600/%E6%93%B7%E5%8F%96.PNG" style="display: block; padding: 1em 0; text-align: center; "><img alt="" border="0" data-original-height="549" data-original-width="1183" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEho4JiGSnOa-XJIMRWEI9Iffico8LsUaEO7b_Ijdnzz_Aw2sjVGFR-jlJ8pOkmpwyfY7t0wIvF5oszqzW9f3NwJh37Bg1So7hfTotNFpvBKi4D70Y3OgrT7fY8F9wVVbTvMn-FKuVDE0vXrmDEWMYMnhqfQPg8xLbs0g7r7y2LDHDX2MywwnLFv0LP6ZLc/s1600/%E6%93%B7%E5%8F%96.PNG"/></a></div>

心得

delet物件的.屬性;增加物件band["singer"]=........

 



<h1>canvas繪圖套件繪製選擇權到期日損益圖</h1>

<canvas id="BuyOptions" width="500" height="300"></canvas>
<script>
const c = document.getElementById("BuyOptions");
const ctx = c.getContext("2d");
ctx.beginPath();
ctx.moveTo(0, 0);
ctx.lineTo(100, 100);
ctx.lineTo(200,100);
ctx.font = "16px Arial";
ctx.fillText("買入賣權puts的到期日損益",0,120);
ctx.moveTo(300, 100);
ctx.lineTo(400, 100);
ctx.lineTo(500, 0);
ctx.fillText("買入買權callss的到期日損益",300,120);
ctx.moveTo(0, 300);
ctx.lineTo(100, 200);
ctx.lineTo(200,200);
ctx.font ="30pt";
ctx.fillText("賣出賣權puts的到期日損益",0,180);
ctx.moveTo(300, 200);
ctx.lineTo(400, 200);
ctx.lineTo(500, 300);
ctx.fillText("賣出買權callss的到期日損益",300,180)
ctx.stroke();//繪製
</script>


canvas繪圖套件繪製選擇權到期日損益圖 截圖

留言

這個網誌中的熱門文章

王鈺嘉canvas與svg繪圖套件

王鈺嘉w3schools學習迴圈