Giter Site home page Giter Site logo

conardli.github.io's Issues

深拷贝函数在处理对象和数组时...

你好最近拜读了您的文章发现写的非常不错,我前前后后读了好几遍 当我去实现的时候我发现了一个问题,在深拷贝函数处理对象或者数组的这个阶段里 我觉得应该要将 symbol 属性加上 Object.keys() 并不能获得健为 symbol 的 value
image
或许这里应该获得包含 symbol 的属性应该要好一些

部分代码是多余的

读了下发现部分代码是多余的:

经过isObject后,显然(Number String Boolean Symbol Undefined Null)这些类型都是不会往下走的而是直接返回的

但是发现cloneOtherType还是有对(Number String Boolean Symbol )的处理,我认为后面应该是没有必要再处理的

while循环效率问题

我对clone4的DEMO文件涉及到的WHILE循环的效率表示质疑,本地测试到的结果(node环境):

clone1 在前,clone2在后, 结果:

undefined: 0.167ms
undefined: 0.126ms

将 clone1 跟 clone2 调下位置,即clone2放在前面,结果:

undefined: 0.254ms
undefined: 0.081ms

即所消耗的时间跟调用的先后顺序有关,而不是WHILE循环的优化结果,不知你怎么看?

postMessage不能跨域通信

window.postMessage() 方法可以安全地实现跨源通信。通常,对于两个不同页面的脚本,只有当执行它们的页面位于具有相同的协议(通常为https),端口号(443为https的默认值),以及主机 (两个页面的模数 Document.domain设置为相同的值) 时,这两个脚本才能相互通信。window.postMessage() 方法提供了一种受控机制来规避此限制,只要正确的使用,这种方法就很安全。
MDN postMessage

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.