var a= 1;var a= 2; //one zero-width charactervar a= 3; //two zero-width characters (or you can use the other one)if(a==1&&a==2&&a==3) {console.log("Why hello there!")}
function A() {var value = 0;this.valueOf = function () { return ++value; };}
var a = new A;
if (a == 1 && a == 2 && a == 3) {console.log('bingo!');}
编辑
使用ES6类,它看起来像这样
class A {constructor() {this.value = 0;this.valueOf();}valueOf() {return this.value++;};}
let a = new A;
if (a == 1 && a == 2 && a == 3) {console.log('bingo!');}
window.__defineGetter__( 'a', function(){if( typeof i !== 'number' ){// define i in the global namespace so that it's not lost after this function runsi = 0;}return ++i;});
if( a == 1 && a == 2 && a == 3 ){console.log( 'Oh dear, what have we done?' );}
const value = function* () {let i = 0;while(true) yield ++i;}();
Object.defineProperty(this, 'a', {get() {return value.next().value;}});
if (a === 1 && a === 2 && a === 3) {console.log('yo!');}
// Main Thread
const worker = new Worker('worker.js')const modifiers = [new Worker('modifier.js'), new Worker('modifier.js')] // Let's use 2 workersconst sab = new SharedArrayBuffer(1)
modifiers.forEach(m => m.postMessage(sab))worker.postMessage(sab)
worker.js
let array
Object.defineProperty(self, 'a', {get() {return array[0]}});
addEventListener('message', ({data}) => {array = new Uint8Array(data)let count = 0do {var res = a == 1 && a == 2 && a == 3++count} while(res == false) // just for clarity. !res is fineconsole.log(`It happened after ${count} iterations`)console.log('You should\'ve never seen this')})
if=()=>!0;var a = 9;
if(a==1 && a== 2 && a==3){document.write("<h1>Yes, it is possible!😎</h1>")}
上面的代码是一个简短的版本(感谢@Forivin在评论中的注释),以下代码是原创的:
var a = 9;
if(a==1 && a== 2 && a==3){//console.log("Yes, it is possible!😎")document.write("<h1>Yes, it is possible!😎</h1>")}
//--------------------------------------------
function if(){return true;}