seems like in ES2015, Template String ${ } syntax will apply toString() to a Buffer object
And under the circumstance of appending multiple strings together, + operator also doing the same thing.
let a = Buffer.from('hello')
let b = () => {
console.log(`es6 : ${a}`) // hello
console.log('es5 : ', a) // <Buffer 68 65 6c 6c 6f>
console.log('es5-2 : ' + a) // hello
console.log(+a) // NaN
}
b()
I can't find enough information on this topic, can anyone explain this ?
via stackoverYC
No comments:
Post a Comment