zswang/jfogs

v1.0 字符串拆分为单个字符连接

zswang opened this issue · 1 comments

字符串拆分为单个字符连接

console.log('hello')
console.log('h' + 'e' + 'l' + 'l' + 'o')

理想的效果

build

Input

console.log(/\w/img.test('hello'));

Step.1

(function() {
  var win = window
  var $console = win['console']
  var $RegExp = win['RegExp']
  $console['log']($RegExp('\\w', 'img')['test']('hello'))
})()

Step.2

(function() {
  var win = window
  var $console = win['c' + 'o' + 'n' + 's' + 'o' + 'l' + 'e']
  var $RegExp = win['R' + 'e' + 'g' + 'E' + 'x' + 'p']
  $console['l' + 'o' + 'g']($RegExp('\\' + 'w', 'i' + 'm' + 'g')['t' + 'e' + 's' + 't']('h' + 'e' + 'l' + 'l' + 'o'))
})()

Step.3

(function($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17) {
  var win = window
  var $console = win[$1 + $2 + $3 + $4 + $2 + $5 + $6]
  var $RegExp = win[$7 + $6 + $8 + $9 + $10 + $11]
  $console[$5 + $2 + $8]($RegExp($12 + $13, $14 + $15 + $8)[$16 + $6 + $4 + $16]($17 + $6 + $5 + $5 + $2))
})('c', 'o', 'n', 's', 'l', 'e', 'R', 'g', 'E', 'x', 'p', '\\', 'w', 'i', 'm', 't', 'h')

Output

!function(n,i,o,w,c,t,a,d,e,f,g,h,l,m,p,r,s){var u=window,v=u[n+i+o+w+i+c+t],x=u[a+t+d+e+f+g];v[c+i+d](x(h+l,m+p+d)[r+t+w+r](s+t+c+c+i))}("c","o","n","s","l","e","R","g","E","x","p","\\","w","i","m","t","h");