Giter Club home page Giter Club logo

asker's People

Contributors

jasminehua avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

asker's Issues

位操作符

问题

(2.9|0) // => 2
(~~2.9) // => 2
(2.9) >>> 0 // => 2
(2.9) >> 0 // => 2
(-2.9) >> 0 //=> -2

为什么位操作符可以取整。小数在计算机中也是以二进制存储的。位操作符是只会保留32位的左操作数么?

记录

(7) >> 1 // => 3
(-7) >> 1 //=> -4

有符号右移会将左操作数转换为32位整数。负数十进制转二进制位补码。
例:
-32
第一步:32(10)=00100000(2)
第二步:求反 11011111
第三步:加1 11100000

联等赋值

var a = {n : 1}
a.x = a = {n : 2} 
console.log(a) // =>{n: 2}
a.x = {n : 2}
console.log(a) // =>{n: 2, x: Object}

按照es5规范a.x = a = {n : 2}等价于a.x = (a = {n : 2})。在(a = {n : 2})执行后a指向{n : 2}并返回{n : 2}。接着应执行a.x = {n : 2},可执行后输出a并未出现{n: 2, x: Object}的预期结果

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.