Last active
January 17, 2020 18:56
-
-
Save mrtampan/eaae06e603ad5173e0387c287ca8b119 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
<script> | |
// contoh benar | |
let a = ""; | |
function aku(){ | |
a = "apa cuk"; | |
alert(a); | |
} | |
aku(); | |
// contoh benar dalam scope | |
function dia(){ | |
let b = ""; | |
b = "coeg"; | |
alert(b); | |
} | |
dia(); | |
// contoh salah | |
function kamu(){ | |
let b = ""; | |
} | |
b = "kita temenan aja"; | |
alert(b); | |
// contoh salah beda scope | |
function kamu(){ | |
let b = "kita temenan aja"; | |
} | |
function aku(){ | |
b = "kamu yakin"; | |
} | |
alert(b); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment