發表文章

Javascript麻瓜:callback 是什麼? For Javascript Muggle: What is callback Simply put: A callback is a function that is to be executed after another function has finished executing — hence the name ‘call back’. More complexly put: In JavaScript, functions are objects. Because of this, functions can take functions as arguments, and can be returned by other functions. Functions that do this are called higher-order functions . Any function that is passed as an argument is called a callback function . Example 1, function sayHello()  {     console.log('Hello everyone'); } setTimeout(sayHello(), 3000) function sayHello() is a function and it is passed as an argument of the function setTimeout, i.e. the function setTimeout takes the fucntion sayHello() as its argument. setTimeout is called a higher-order function. sayHello() is called a callback function. The callback function sayHello() is executed after 3000 miliseconds is past.  Callbacks ...
Javascript麻瓜的練習:Parse URL Exercise for Javascript Muggle: Parse URL Create a function called parse_URL to parse the URL: https://example.com:4000/folder/page.html?x=y&a=b#section-2 //please refer the link to complete the exercise: https://developer.mozilla.org/zh-TW/docs/Web/API/URL/URL The function should print the following text to the console:  source: https://example.com:4000/folder/page.html?x=y&a=b#section-2 protocol: https host: example.com port: 4000 query:x=y,a=b path:  /folder/page.html hash:  section-2 segments:  [ '', 'folder', 'page.html' ] Sample codes ============================================================================= function parse_URL(myURL) {     var a = new URL(myURL);          urlObj= {         source: myURL,         host: a.hostname,      ...
圖片
食譜  Recipe - Butter Cookies 奶油曲奇 Butter Cookies: 低筋麵粉 cake flour:100g 糖 Sugar:35g  香草精 Vanilla extract :2/1 茶匙 teaspoon 蛋黃 Yolk: 1 鹽 salt:少許 a bit 鮮奶 milk: 15 ml (加鮮奶,只是要在擠花時好擠一點。加太多的話,烤的時候,餅乾的花紋會不見喔。加太少,擠花會擠到手殘廢。自己得在份量上自行斟酌。) 原味 Original flavor:杏仁粉 Almond powder 40g 抹茶 Matcha flavor:杏仁粉 Almond powder 25g,抹茶粉 Matcha powder 15g 巧克力 chocolate flavor:杏仁粉 Almond powder 25g,可可粉 chocolate poweder 15g (The current article has not been finished. I will update it later on ....  本文尚未完成,更新持續中 ...) 原味曲奇   巧克力曲奇