var str = 'abc'; var a = new Buffer(6); a.fill(str); console.log(a.toString());
-
在
3.2.0-67-generic #101-Ubuntu SMP Tue Jul 15 17:46:11 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
结果为aaaaaa
-
在
mac osx
上为abcabc
var a = { b: new Buffer('aadf') } console.log(JSON.stringify(a))
-
在
3.2.0-67-generic #101-Ubuntu SMP Tue Jul 15 17:46:11 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
结果为{"b":[97,97,100,102]}
-
在
mac osx
上为{"b":{"type":"Buffer","data":[97,102]}}