c语言变量unicode_Unicode JavaScript变量和函数

c语言变量unicode

We all get a kick out of unicode symbols, as we all saw in my Unicode CSS Classes post, and just as we can use them for CSS classes, we can use them for JavaScript variables and functions as well!  Let's say you want to shave a few bytes of post-minified JavaScript byes by setting false equal to a variable.  Why not do so by using a unicode variable?

正如我们在Unicode CSS Classes文章中所看到的,我们所有人都从Unicode符号受益匪浅 ,就像我们可以将它们用于CSS类一样,我们也可以将它们用于JavaScript变量和函数! 假设您要通过将false设置为变量来剃除缩小后JavaScript代码的几个字节。 为什么不通过使用unicode变量来这样做呢?


var ಠ_ಠ = false;

if(someVar === ಠ_ಠ) { // If someVar is false...
	// ...
}


Hilarious.  The evil eyes signal a negative result.  What about saving a few byes on true?  The Beatles once said that "All You Need is Love", so let's use a heart:

搞笑 邪恶的眼睛预示着负面的结果。 真的可以节省一些费用吗? 甲壳虫乐队曾经说过: “你所需要的就是爱” ,所以让我们用一颗心:


var ❤ = true;

if(someVar === ❤) {
	// ...
}


You can do the same with function names.  Functions can be named after unicode symbols:

您可以对函数名称执行相同的操作。 可以用unicode符号命名函数:


function ಠ(arg) {
	// ...
}


Of course all of this is a bit ... insane, and you should never use unicode symbols, but nonetheless it's possible.  Imagine starting a new job and seeing those symbols as meaningful variables -- you'd quit immediately!  Hilarious!

当然,所有这些都有点……疯了,您不应该使用unicode符号,但是仍然可以。 想象一下开始新工作并将这些符号视为有意义的变量-您将立即退出! 搞笑!

翻译自: https://davidwalsh.name/unicode-javascript

c语言变量unicode

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值