GithubHelp home page GithubHelp logo

Comments (7)

DakerHub avatar DakerHub commented on May 1, 2024 29

没有10年脑血栓应该写不出这种代码

from fe-interview.

Genzhen avatar Genzhen commented on May 1, 2024 6

答案
1 undefined

解析
条件判断为假的情况有:0,false,'',null,undefined,未定义对象。函数声明写在运算符中,其为true,但放在运算符中的函数声明在执行阶段是找不到的。另外,对未声明的变量执行typeOf不会报错,会返回undefined

from fe-interview.

yanwenxi avatar yanwenxi commented on May 1, 2024

结果应该是NaN吧,1+undefined=NaN

from fe-interview.

Genzhen avatar Genzhen commented on May 1, 2024

结果应该是NaN吧,1+undefined=NaN

typeof 返回的是字符串哦

from fe-interview.

liuyuan22 avatar liuyuan22 commented on May 1, 2024

放在运算符中的函数声明在执行阶段是找不到的

理解这个意思,但是这种行为是写在规范里的么?找了一圈没找到,有没有什么出处?

from fe-interview.

wind8866 avatar wind8866 commented on May 1, 2024

函数声明写在运算符中,其为true,但放在运算符中的函数声明在执行阶段是找不到的。

@Genzhen 不太理解这句话的意思。

我测试在严格模式下,chrome 执行结果为1function
个人理解,函数声明会被提升到所有代码执行前,所以在整个代码任何地方都能访问到f。

from fe-interview.

luzhaopan avatar luzhaopan commented on May 1, 2024

1object
image

from fe-interview.

Related Issues (20)

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.