美文网首页
笔记(1)

笔记(1)

作者: 快到碗里 | 来源:发表于2020-02-11 22:01 被阅读0次

**find()** 方法返回数组中满足提供的测试函数的第一个元素的值。否则返回 [undefined]

const array1 = [5, 12, 8, 130, 44];
const found = array1.find(element => element > 10);
console.log(found);
// expected output: 12

JSON.stringify()的作用是将 JavaScript 对象转换为 JSON 字符串
JSON.parse()可以将JSON字符串转为一个对象。

JSON.stringify()与toString()的区别

这两者虽然都可以将目标值转为字符串,但本质上还是有区别的,比如

let arr = [1,2,3];
JSON.stringify(arr);//'[1,2,3]'
arr.toString();//1,2,3

相关文章

网友评论

      本文标题:笔记(1)

      本文链接:https://www.haomeiwen.com/subject/jxuffhtx.html