This is the source file
import jsffi
var console {.importc, nodecl.}: JsObject
type Person = object
name: string
age: int32
var p: Person
p.name = "foo"
p.age = 90
console.log(p)
in the output js, the str literal is assigned via makeNimstrLit:
var p_129019 = [{
name: null,
age: 0
}];
p_129019[0].name = nimCopy(null, makeNimstrLit("foo"), NTI47014);
p_129019[0].age = 90;
console.log((p_129019[0]));
This results in output like:
{ name: [ 102, 111, 111 ], age: 90 }
instead of:
{ name: 'foo', age: 90 }
You can't emulate Nim's strings which are mutable and utf8 with JS strings which are immutable and utf16. So instead Nim uses JS array of integers acting as bytes (0 to 255) to implement strings.
JS strings have a ton of crazy properties which Nim strings don't have. See https://mathiasbynens.be/notes/javascript-unicode
But some times using JS strings in JS compile mode is useful I have defined some methods to make it easier and faster: https://github.com/treeform/jsutils/blob/master/src/jsutils/strings.nim