Code Monkey home page Code Monkey logo

Comments (10)

wuyongyu avatar wuyongyu commented on July 20, 2024

from fe-knowledge.

wuyongyu avatar wuyongyu commented on July 20, 2024
  • 判断一个值是否是NaN,标准的库函数isNaN也不可靠

比如:

isNaN(NaN); // true
isNaN(undefined); // true
isNaN({}); // true
  • 可以通过下面的函数进行判断
function isReallyNaN(x){
    return x !== x;
}

from fe-knowledge.

wuyongyu avatar wuyongyu commented on July 20, 2024
  • 理解JavaScript的浮点数
0.1 + 0.2; // 0.30000000000000004

(0.1 + 0.2) + 0.3; // 0.6000000000000001

0.1 + (0.2 + 0.3); // 0.6

所以平时尽可能地采用整数值运算

from fe-knowledge.

wuyongyu avatar wuyongyu commented on July 20, 2024
  • 判断奇偶数可以通过 &(按位与)
  • 比如:
12 & 1 // 0 
23 & 1 // 1

【常用于if语句】,这种写法可读性不高

from fe-knowledge.

wuyongyu avatar wuyongyu commented on July 20, 2024
  • 有时看到另一种 bind 函数的方法
this.foo = ::this.foo; 
  • 等同于下面的语句👇
this.foo = this.foo.bind(this);

【两个冒号的::操作符叫做 bind 操作符】

from fe-knowledge.

wuyongyu avatar wuyongyu commented on July 20, 2024

Erlang 语言的作者 Joe Armstrong 说,面向对象语言的问题是,它们永远都要随身携带那些隐式的环境。你只需要一个香蕉,但却得到一个拿着香蕉的大猩猩...以及整个丛林

from fe-knowledge.

wuyongyu avatar wuyongyu commented on July 20, 2024

React源码中 $$typeof 有什么作用?

  • 所有的 React elements 需要加上 $$typeof: Symbol.for(‘react.element’) 用来解决安全问题。防止 XSS 注入,采用 symbol 方式,在判断是否合法的 element 时,检查 $$typeof 属性

from fe-knowledge.

wuyongyu avatar wuyongyu commented on July 20, 2024

React源码中,为什么会用 0xeac7 ?

// The Symbol used to tag the ReactElement type. If there is no native Symbol
// nor polyfill, then a plain number is used for performance.
var TYPE_SYMBOL = (typeof Symbol === 'function' && Symbol.for &&
                  Symbol.for('react.element')) || 0xeac7;

from fe-knowledge.

wuyongyu avatar wuyongyu commented on July 20, 2024

image

from fe-knowledge.

wuyongyu avatar wuyongyu commented on July 20, 2024

image

正确答案:
script start
async1 start
async2
promise1
script end
async1 end
promise2
undefined
setTimeout

from fe-knowledge.

Related Issues (7)

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.