Last active
October 31, 2016 14:33
-
-
Save KinoAR/c1774808f3a442a47c647e175bd1c13b to your computer and use it in GitHub Desktop.
A gist for my symbols tutorial for RPGMaker MV
This file contains 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
//============================================================================= | |
// Symbols | |
//============================================================================= | |
//Creating Local Symbol | |
var localSymbol = Symbol("My Symbol"); | |
//Creating Global Symbol | |
var mySymbol2 = Symbol.for("My Symbol2"); | |
//Getting and storing a global symbol | |
var mySymbol2dup = Symbol.for("My Symbol2"); | |
//Check if local symbol is equal to global symbol | |
let testString = `Are localSymbol and mySymbol2 the same? : ${localSymbol === mySymbol2}`; | |
console.log(testString);//Are localSymbol and mySymbol2 the same? :false | |
//Check if duplilcate is equal to global symbol | |
testString = `Are mySymbol2 and mySymbol2dup the same? : ${mySymbol2 === mySymbol2dup}`; | |
console.log(testString);//Are mySymbol2 and mySymbol2dup the same? : true | |
//Check for symbols in global symbol registry | |
console.log(`Local Symbol key: ${Symbol.keyFor(localSymbol)}`); // Local Symbol key: Undefined | |
console.log(`Global Symbol key: ${Symbol.keyFor(mySymbol2)}`); //Global Symbol key: My Symbol2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment