Forum Discussion
impossible to set a variable to (blank) using JavaScript from an external source?
@Owen your method works, but as a JavaScript novice the syntax:
var string = "";
window.GetPlayer().SetVar(string);
made more sense to me. Just throwing this out there in case it's useful to other novices like myself.
- OwenHolt4 years agoSuper Hero
There are absolutely multiple ways to do this and the method you proposed does create a variable as a string. Specifically, it creates a string literal.
Normally, JavaScript strings are primitive values, created from literals:
let x = "John";But strings can also be defined as objects with the keyword new:
let y = new String("John");Interestingly enough, these 2 things are not equal.
If you tested to see if the values of x and y above were the same (x==y) it would return "true".
However, if you tested to see if the value and the type were the same (x===y) it would return false.For this specific question, either will do, but in the spirit of moving you from Novice forward, just know that there is a difference and how you declare a variable can matter.