Javascript Data Type Question Convert to String via String()

Introduction

What is the output of the following code?

// Converting any value to a string
let numberString = String(3.1415);
let numberString2 = 3.14159 + '';
let arrayString = String([1,'test',3,true,5]);
let objectString = String({'hello':'world', 'random':'object'});
let nullString = String(null);

console.log(typeof numberString + ': ' + numberString);
console.log(typeof numberString2 + ': ' + numberString2);
console.log(typeof arrayString + ': ' + arrayString);
console.log(typeof objectString + ': ' + objectString);
console.log(typeof nullString + ': ' + nullString);


string: 3.1415
string: 3.14159
string: 1,test,3,true,5
string: [object Object]
string: null



PreviousNext

Related