// js对象和json 的区别 var friend ={ firstname:‘zhang‘, lastname:‘cl‘, address:null, // address:‘‘, // address:undefined, }; // var str = ‘{"name":"alan"}‘; // json 格式对象 var json ={ "name":"alan", "age":"23", "gender":"female", }; // json 格式数组 var arr =[ { "name":"alan", "age":"23", "gender":"female", }, { "name":"kitty", "age":"23", "gender":"female", }, { "name":"tom", "age":"23", "gender":"male", } ] var json2 = JSON.parse(str); // json 格式的对象 // var str = JSON.stringify(friend); var str2 = ‘{"firstname":"zhang","lastname":"cl","address":null}‘; var json3 = {"firstname":"zhang","lastname":"cl","address":null} // console.log(str); console.log(typeof(json3));
时间: 2024-10-25 09:00:54