Quantcast
Channel: ClearScript
Viewing all articles
Browse latest Browse all 2297

New Post: Weird Parameter Passing Behavior

0
0
Hi JC,

Is there an easy way to read the string object as a string without using the .toString() function in JS itself?

Sure, you can call toString() or valueOf() from the host:
s = engine.getChunkJSON(num).valueOf()
Of course, this will break if getChunkJSON() changes and starts returning normal strings.

In general we don't recommend explicit usage of JavaScript's String, Number, or Boolean objects, as their behavior can be unexpected:
if (new String('foo') == new String('foo')) {
    // code here WILL NOT be executed
}
if (new Boolean(false)) {
    // code here WILL be executed
}
Good luck!

Viewing all articles
Browse latest Browse all 2297

Latest Images

Trending Articles





Latest Images