Coder Social home page Coder Social logo

Comments (7)

adward321 avatar adward321 commented on August 16, 2024 1

试过了,是可以的。
感谢不吝赐教,学习了。
持续关注

from h-blog.

hooper-hc avatar hooper-hc commented on August 16, 2024

@zaqwsxcderfvtgb 非常感谢阅读和提的 ISSUE,这些对我意义重大!

此问题应该是出自此篇博客: https://github.com/HCThink/h-blog/blob/master/interesting/in1.md


你是在电脑上看的么? 为何 copy 出来在 console 中试一试?

image

from h-blog.

adward321 avatar adward321 commented on August 16, 2024

我在Chrome控制台试的不行
var a = 1; var 1 = a; var 2 = a; var 3 = a;
报错:Uncaught SyntaxError: Unexpected number

from h-blog.

hooper-hc avatar hooper-hc commented on August 16, 2024

@zaqwsxcderfvtgb 非常感谢阅读和提的 ISSUE,这些对我意义重大!


你得复制上面的代码到 console 中执行, 上述的变量经过特殊处理。

这个问题和 文章中提到的

  • amazed 最让我吃惊的方案
var aᅠ = 1;
var a = 2;
var ᅠa = 3;
if(aᅠ ==1 && a == 2 && ᅠa ==3) {
    console.log("Why hello there!")
}

原理一样, 其中的三个 a 是不同字符和 a 组合出来的

这里的 var ᅠ1 = a; 中的 ᅠ1 并不是数字,他前面有个别的字符集,渲染不出来。

最简单的方式, 你试着删除这个 1 ᅠ 就会发现要删两次。

from h-blog.

adward321 avatar adward321 commented on August 16, 2024

刚才可以打印出来了,也就是说这个a是前后加空格代表的字符集组成的变量,但是现在不报错,只是打印出来的是false,
var a = 1; var ᅠ1 = a; var ᅠ2 = a; var ᅠ3 = a; console.log(aᅠ ==1 && a == 2 && ᅠa ==3)
VM246:4 false

from h-blog.

hooper-hc avatar hooper-hc commented on August 16, 2024

刚才可以打印出来了,也就是说这个a是前后加空格代表的字符集组成的变量,但是现在不报错,只是打印出来的是false,
var a = 1; var ᅠ1 = a; var ᅠ2 = a; var ᅠ3 = a; console.log(aᅠ ==1 && a == 2 && ᅠa ==3)
VM246:4 false

@zaqwsxcderfvtgb 这是你敲的么 ? 逻辑是不对的, 这种思路下,假设特殊字符是 * ,你的代码应该这么写:

var a = 10;
var *1 = a;
var *2 = a;
var *3 = a;
console.log(a == *1 && a == *2 && a == *3 )

你声明没问题,但是 console.log 中的123是普通的123, 肯定 false 啊


你从原文中复制代码出来 跑一下,是没问题的

var  a = 1;
var ᅠ1 = a;
var ᅠ2 = a;
var ᅠ3 = a;
console.log( a ==ᅠ1 && a ==ᅠ2 && a ==ᅠ3 );

image

from h-blog.

hooper-hc avatar hooper-hc commented on August 16, 2024

试过了,是可以的。
感谢不吝赐教,学习了。
持续关注

客气了,我还怕表达的不清楚呢,感谢提 issue

from h-blog.

Related Issues (13)

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.