Created
May 25, 2021 17:00
-
-
Save channyeintun/59e064b84a9b089ecf7fe1ce3831bdf1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
အရင်ကရေးဖူးတယ်။ | |
Global Scope မှာရေးထားတဲ့ JavaScript Function တစ်ခုကို ဘယ်နှနည်းနဲ.ခေါ်လို.ရနိုင်ပါသလဲ :3 | |
function hello() | |
{ | |
console.log("JavaScript"); | |
} | |
hello(); | |
hello.call(); | |
hello.apply(); | |
hello.bind()(); | |
this.hello(); | |
this.hello.call(); | |
this.hello.apply(); | |
this.hello.bind()(); | |
this["hello"](); | |
this["hello"].call(); | |
this["hello"].apply(); | |
this["hello"].bind()(); | |
window.hello(); | |
window.hello.call(); | |
window.hello.apply(); | |
window.hello.bind()(); | |
window["hello"](); | |
window["hello"].call(); | |
window["hello"].apply(); | |
window["hello"].bind()(); | |
new hello(); | |
ဒါကတော့ () parenthesis မပါပဲ call တဲ့နည်းပါ။ | |
new hello; | |
နောက် getter,setter တွေသုံးပြီး ခေါ်မယ်ဆိုလဲ () parenthesis မပါပဲသုံးလို.ရနိုင်ပါတယ် | |
var obj = { | |
get hello() | |
{ | |
console.log("Hello"); | |
}, | |
set hello(arg) | |
{ | |
console.log("Hello"); | |
} | |
}; | |
obj.hello | |
obj.hello = ""; | |
Object.defineProperty ကိုသုံးရင်လဲ ရပါတယ် 🙂 | |
Firefox မှာ support ပေးထားတဲ့ __noSuchMethod__ ကိုသုံးရင် Infinity ဖြစ်ပါလိမ့်မယ် (no Such method က မရှိတဲ့ method တခုကိုခေါ်ရင် ထအလုပ်လုပ်တယ် ) | |
obj.__noSuchMethod__ = function() | |
{ | |
console.log("Hello"); | |
} | |
obj.blahBlah() | |
//Have fun and now claim yourself JS Ninja 😛 | |
Credit Ko Thet Khine |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment