Coder Social home page Coder Social logo

Comments (3)

ustchcl avatar ustchcl commented on June 17, 2024 4

4f14f5d

from interview.

qappleh avatar qappleh commented on June 17, 2024

答案:
11
4
1,22,1
aNaN

解析:
1 + "1"
加性操作符:如果只有一个操作数是字符串,则将另一个操作数转换为字符串,然后再将两个字符串拼接起来

所以值为:“11”

2 * "2"
乘性操作符:如果有一个操作数不是数值,则在后台调用 Number()将其转换为数值。

所以值为4

[1, 2] + [2, 1]
Javascript中所有对象基本都是先调用valueOf方法,如果不是数值,再调用toString方法。

所以两个数组对象的toString方法相加,值为:"1,22,1"

"a" + + "b"
后边的“+”将作为一元操作符,如果操作数是字符串,将调用Number方法将该操作数转为数值,如果操作数无法转为数值,则为NaN。

所以值为:"aNaN"

以上均参考:《Javascript高级程序设计》

from interview.

qiqingfu avatar qiqingfu commented on June 17, 2024

@qappleh 顶一个

from 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.