weak和assign的区别-正确使用weak.assign 一.区别 1.修饰变量类型的区别weak只可以修饰对象.如果修饰基本数据类型,编译器会报错-“Property with ‘weak’ attribute must be of object type”.assign可修饰对象,和基本数据类型.当需要修饰对象类型时,MRC时代使用unsafe_unretained.当然,unsafe_unretained也可能产生野指针,所以它名字是"unsafe_”. 2.是否产生野指针的区别wea
Best Pratices for Object.assign: http://www.cnblogs.com/Answer1215/p/5096746.html Object.assign() can extend the object by adding new props: let obj = { first_name: 'Zhentian', age: 27 } Object.assign(obj, {last_name: 'Wan'}); console.log(obj); log o
Learn how to use Object.assign() and the spread operator proposed for ES7 to avoid mutating objects. /* * Open the console to see * that the tests have passed. */ const toggleTodo = (todo) => { return { ...todo, completed: !todo.completed }; }; const