摘要:如果類型轉(zhuǎn)換你還不是很了解,可以先讀下這篇來理解一下從看隱式強(qiáng)制轉(zhuǎn)換機(jī)制。函數(shù)可對通過編碼的字符串進(jìn)行解碼。而作者封裝的也是基于這兩者來實(shí)現(xiàn)輸出黑魔法字符串的。同時(shí)通過,返回了一個(gè)匿名函數(shù)形成了閉包。為了達(dá)到裝逼的效果。
寫在最前
事情的起因是這段看起來不像代碼的代碼:
有興趣的同學(xué)可以自己先嘗試下!
([]+[][(![]+[])[!+[]+!![]+!![]]+([]+{})[+!![]]+(!![]+[])[+!![]]+(!![]+[])[+[]]][([]+{})[!+[]+!![]+!![]+!![]+!![]]+([]+{})[+!![]]+([][[]]+[])[+!![]]+(![]+[])[!+[]+!![]+!![]]+(!![]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+[]]+([]+{})[!+[]+!![]+!![]+!![]+!![]]+(!![]+[])[+[]]+([]+{})[+!![]]+(!![]+[])[+!![]]]((!![]+[])[+!![]]+([][[]]+[])[!+[]+!![]+!![]]+(!![]+[])[+[]]+([][[]]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+!![]]+([]+{})[!+[]+!![]+!![]+!![]+!![]+!![]+!![]]+(![]+[])[!+[]+!![]]+([]+{})[+!![]]+([]+{})[!+[]+!![]+!![]+!![]+!![]]+(+{}+[])[+!![]]+(!![]+[])[+[]]+([][[]]+[])[!+[]+!![]+!![]+!![]+!![]]+([]+{})[+!![]]+([][[]]+[])[+!![]])())[+[]]+([][[]]+[])[!+[]+!![]+!![]]+(![]+[])[!+[]+!![]]+(![]+[])[!+[]+!![]]+([]+{})[+!![]]+([]+{})[!+[]+!![]+!![]+!![]+!![]+!![]+!![]]+[][(![]+[])[!+[]+!![]+!![]]+([]+{})[+!![]]+(!![]+[])[+!![]]+(!![]+[])[+[]]][([]+{})[!+[]+!![]+!![]+!![]+!![]]+([]+{})[+!![]]+([][[]]+[])[+!![]]+(![]+[])[!+[]+!![]+!![]]+(!![]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+[]]+([]+{})[!+[]+!![]+!![]+!![]+!![]]+(!![]+[])[+[]]+([]+{})[+!![]]+(!![]+[])[+!![]]]((!![]+[])[+!![]]+([][[]]+[])[!+[]+!![]+!![]]+(!![]+[])[+[]]+([][[]]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+!![]]+([]+{})[!+[]+!![]+!![]+!![]+!![]+!![]+!![]]+([][[]]+[])[+[]]+([][[]]+[])[+!![]]+([][[]]+[])[!+[]+!![]+!![]]+(![]+[])[!+[]+!![]+!![]]+([]+{})[!+[]+!![]+!![]+!![]+!![]]+(+{}+[])[+!![]]+([]+[][(![]+[])[!+[]+!![]+!![]]+([]+{})[+!![]]+(!![]+[])[+!![]]+(!![]+[])[+[]]][([]+{})[!+[]+!![]+!![]+!![]+!![]]+([]+{})[+!![]]+([][[]]+[])[+!![]]+(![]+[])[!+[]+!![]+!![]]+(!![]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+[]]+([]+{})[!+[]+!![]+!![]+!![]+!![]]+(!![]+[])[+[]]+([]+{})[+!![]]+(!![]+[])[+!![]]]((!![]+[])[+!![]]+([][[]]+[])[!+[]+!![]+!![]]+(!![]+[])[+[]]+([][[]]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+!![]]+([]+{})[!+[]+!![]+!![]+!![]+!![]+!![]+!![]]+(![]+[])[!+[]+!![]]+([]+{})[+!![]]+([]+{})[!+[]+!![]+!![]+!![]+!![]]+(+{}+[])[+!![]]+(!![]+[])[+[]]+([][[]]+[])[!+[]+!![]+!![]+!![]+!![]]+([]+{})[+!![]]+([][[]]+[])[+!![]])())[!+[]+!![]+!![]]+([][[]]+[])[!+[]+!![]+!![]])()([][(![]+[])[!+[]+!![]+!![]]+([]+{})[+!![]]+(!![]+[])[+!![]]+(!![]+[])[+[]]][([]+{})[!+[]+!![]+!![]+!![]+!![]]+([]+{})[+!![]]+([][[]]+[])[+!![]]+(![]+[])[!+[]+!![]+!![]]+(!![]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+[]]+([]+{})[!+[]+!![]+!![]+!![]+!![]]+(!![]+[])[+[]]+([]+{})[+!![]]+(!![]+[])[+!![]]]((!![]+[])[+!![]]+([][[]]+[])[!+[]+!![]+!![]]+(!![]+[])[+[]]+([][[]]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+!![]]+([]+{})[!+[]+!![]+!![]+!![]+!![]+!![]+!![]]+([][[]]+[])[!+[]+!![]+!![]]+(![]+[])[!+[]+!![]+!![]]+([]+{})[!+[]+!![]+!![]+!![]+!![]]+(+{}+[])[+!![]]+([]+[][(![]+[])[!+[]+!![]+!![]]+([]+{})[+!![]]+(!![]+[])[+!![]]+(!![]+[])[+[]]][([]+{})[!+[]+!![]+!![]+!![]+!![]]+([]+{})[+!![]]+([][[]]+[])[+!![]]+(![]+[])[!+[]+!![]+!![]]+(!![]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+[]]+([]+{})[!+[]+!![]+!![]+!![]+!![]]+(!![]+[])[+[]]+([]+{})[+!![]]+(!![]+[])[+!![]]]((!![]+[])[+!![]]+([][[]]+[])[!+[]+!![]+!![]]+(!![]+[])[+[]]+([][[]]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+!![]]+([]+{})[!+[]+!![]+!![]+!![]+!![]+!![]+!![]]+(![]+[])[!+[]+!![]]+([]+{})[+!![]]+([]+{})[!+[]+!![]+!![]+!![]+!![]]+(+{}+[])[+!![]]+(!![]+[])[+[]]+([][[]]+[])[!+[]+!![]+!![]+!![]+!![]]+([]+{})[+!![]]+([][[]]+[])[+!![]])())[!+[]+!![]+!![]]+([][[]]+[])[!+[]+!![]+!![]])()(([]+{})[+[]])[+[]]+(!+[]+!![]+!![]+!![]+!![]+!![]+!![]+[])+(!+[]+!![]+!![]+!![]+!![]+!![]+!![]+[]))+([]+{})[+!![]]+(!![]+[])[+!![]]+(![]+[])[!+[]+!![]]+([][[]]+[])[!+[]+!![]]+[][(![]+[])[!+[]+!![]+!![]]+([]+{})[+!![]]+(!![]+[])[+!![]]+(!![]+[])[+[]]][([]+{})[!+[]+!![]+!![]+!![]+!![]]+([]+{})[+!![]]+([][[]]+[])[+!![]]+(![]+[])[!+[]+!![]+!![]]+(!![]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+[]]+([]+{})[!+[]+!![]+!![]+!![]+!![]]+(!![]+[])[+[]]+([]+{})[+!![]]+(!![]+[])[+!![]]]((!![]+[])[+!![]]+([][[]]+[])[!+[]+!![]+!![]]+(!![]+[])[+[]]+([][[]]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+!![]]+([]+{})[!+[]+!![]+!![]+!![]+!![]+!![]+!![]]+([][[]]+[])[+[]]+([][[]]+[])[+!![]]+([][[]]+[])[!+[]+!![]+!![]]+(![]+[])[!+[]+!![]+!![]]+([]+{})[!+[]+!![]+!![]+!![]+!![]]+(+{}+[])[+!![]]+([]+[][(![]+[])[!+[]+!![]+!![]]+([]+{})[+!![]]+(!![]+[])[+!![]]+(!![]+[])[+[]]][([]+{})[!+[]+!![]+!![]+!![]+!![]]+([]+{})[+!![]]+([][[]]+[])[+!![]]+(![]+[])[!+[]+!![]+!![]]+(!![]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+[]]+([]+{})[!+[]+!![]+!![]+!![]+!![]]+(!![]+[])[+[]]+([]+{})[+!![]]+(!![]+[])[+!![]]]((!![]+[])[+!![]]+([][[]]+[])[!+[]+!![]+!![]]+(!![]+[])[+[]]+([][[]]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+!![]]+([]+{})[!+[]+!![]+!![]+!![]+!![]+!![]+!![]]+(![]+[])[!+[]+!![]]+([]+{})[+!![]]+([]+{})[!+[]+!![]+!![]+!![]+!![]]+(+{}+[])[+!![]]+(!![]+[])[+[]]+([][[]]+[])[!+[]+!![]+!![]+!![]+!![]]+([]+{})[+!![]]+([][[]]+[])[+!![]])())[!+[]+!![]+!![]]+([][[]]+[])[!+[]+!![]+!![]])()([][(![]+[])[!+[]+!![]+!![]]+([]+{})[+!![]]+(!![]+[])[+!![]]+(!![]+[])[+[]]][([]+{})[!+[]+!![]+!![]+!![]+!![]]+([]+{})[+!![]]+([][[]]+[])[+!![]]+(![]+[])[!+[]+!![]+!![]]+(!![]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+[]]+([]+{})[!+[]+!![]+!![]+!![]+!![]]+(!![]+[])[+[]]+([]+{})[+!![]]+(!![]+[])[+!![]]]((!![]+[])[+!![]]+([][[]]+[])[!+[]+!![]+!![]]+(!![]+[])[+[]]+([][[]]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+!![]]+([]+{})[!+[]+!![]+!![]+!![]+!![]+!![]+!![]]+([][[]]+[])[!+[]+!![]+!![]]+(![]+[])[!+[]+!![]+!![]]+([]+{})[!+[]+!![]+!![]+!![]+!![]]+(+{}+[])[+!![]]+([]+[][(![]+[])[!+[]+!![]+!![]]+([]+{})[+!![]]+(!![]+[])[+!![]]+(!![]+[])[+[]]][([]+{})[!+[]+!![]+!![]+!![]+!![]]+([]+{})[+!![]]+([][[]]+[])[+!![]]+(![]+[])[!+[]+!![]+!![]]+(!![]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+[]]+([]+{})[!+[]+!![]+!![]+!![]+!![]]+(!![]+[])[+[]]+([]+{})[+!![]]+(!![]+[])[+!![]]]((!![]+[])[+!![]]+([][[]]+[])[!+[]+!![]+!![]]+(!![]+[])[+[]]+([][[]]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+!![]]+([]+{})[!+[]+!![]+!![]+!![]+!![]+!![]+!![]]+(![]+[])[!+[]+!![]]+([]+{})[+!![]]+([]+{})[!+[]+!![]+!![]+!![]+!![]]+(+{}+[])[+!![]]+(!![]+[])[+[]]+([][[]]+[])[!+[]+!![]+!![]+!![]+!![]]+([]+{})[+!![]]+([][[]]+[])[+!![]])())[!+[]+!![]+!![]]+([][[]]+[])[!+[]+!![]+!![]])()(([]+{})[+[]])[+[]]+(!+[]+!![]+[])+(+!![]+[]))
作者對著這段代碼足足看了一下午,我只想說這不是什么深?yuàn)W的黑魔法。一點(diǎn)點(diǎn)看下來你就知道其中的原理了。最后會(huì)有一段作者自己封裝的代碼叫nb.js(源碼在這里),它實(shí)現(xiàn)了輸入數(shù)字字母后自動(dòng)生成這種玄學(xué)代碼片段。就像這樣:
歡迎關(guān)注我的博客,不定期更新中——
JavaScript小眾系列開始更新啦——何時(shí)完結(jié)不確定,寫多少看我會(huì)多少!這是已經(jīng)更新的地址:
小眾系列之按位非運(yùn)算符:JavaScript中奇特的~運(yùn)算符
小眾系列之終極類型轉(zhuǎn)換:從hello world看JavaScript隱藏的黑魔法制
小眾系列之隱式類型轉(zhuǎn)換:[從[] == ![]看隱式強(qiáng)制轉(zhuǎn)換機(jī)制](https://github.com/Aaaaaaaty/...
小眾系列之事件循環(huán):從HTML5與PromiseA+規(guī)范來看事件循環(huán)
這個(gè)系列旨在對一些人們不常用遇到的知識(shí)點(diǎn),以及可能常用到但不曾深入了解的部分做一個(gè)重新梳理,雖然可能有些部分看起來沒有什么用,因?yàn)槠綍r(shí)開發(fā)真的用不到!但個(gè)人認(rèn)為糟粕也好精華也罷里面全部蘊(yùn)藏著JS一些偏本質(zhì)的東西或者說底層規(guī)范,如果能適當(dāng)避開舒適區(qū)來看這些小細(xì)節(jié),也許對自己也會(huì)有些幫助~文章更新在我的博客,歡迎不定期關(guān)注。
轉(zhuǎn)換思路 基礎(chǔ)思路:通過關(guān)鍵字來獲取字母什么意思?比如:f。看到f你會(huì)想到哪個(gè)關(guān)鍵字?同時(shí)這個(gè)關(guān)鍵字是要在類型轉(zhuǎn)換的機(jī)制下能夠被打印出來的。如果類型轉(zhuǎn)換你還不是很了解,可以先讀下這篇來理解一下:[從[] == ![]看隱式強(qiáng)制轉(zhuǎn)換機(jī)制](https://github.com/Aaaaaaaty/...。我相信很多同學(xué)可以想到是false這個(gè)關(guān)鍵字。那么我們的思路就有了也就是要讓代碼實(shí)現(xiàn)"false"[0]這件事,這個(gè)認(rèn)識(shí)統(tǒng)一之后我相信下面的代碼一定不難理解了:
[[[] == []] + []][+![]][+![]] //過程理解為 [] == [] => false [[] == []] => [false] [[[] == []] + []] => ["false"], [+![]] => 0 [[[] == []] + []][+![]] => "false" [[[] == []] + []][+![]][+![]] => "false"[0] => "f"
其中大體形式可以理解為:"false"[0] => "f"
是不是瞬間覺得也不過如此?
可通過關(guān)鍵字獲取的字符當(dāng)你知道可以用上面的方式來獲取自己需要的字母之后,接下來要做的是思考一下你能從關(guān)鍵字中獲取哪些字母呢,作者總結(jié)了以下你可以通過關(guān)鍵字獲得的字母:
([][[]]+[]) => "undefined" +[1+[[][0]+[]][0][3]+400][0]+[] => "Infinity" [[[] == []] + []][+![]] => "false" [[[] != []] + []][+![]] => "true" ([]+{}) => "[object Object]"
感興趣的同學(xué)自己打印下就明白為什么了。
接下來要說的是剩下的字母怎么辦?當(dāng)然了你仍然可以通過試圖尋找關(guān)鍵字的方式來獲取字母。但是如果標(biāo)點(diǎn)我也想要呢?或者說26個(gè)字母我都想要怎么辦?
具體點(diǎn)來說對于“hello world!”這段字符串來看,至少“w”,"!"的獲取方法通過關(guān)鍵字的形式我們是無從下手的。
unescape() 函數(shù)可對通過 escape() 編碼的字符串進(jìn)行解碼。但是已經(jīng)廢棄了
是的現(xiàn)在已經(jīng)不建議如此使用了,但是瀏覽器下基本還是支持這個(gè)函數(shù)的。通過這個(gè)函數(shù)我們可以通過ascll碼來直接得到我們需要的字符:
unescape("%77") => "w"
如此看來,除了我們可以快速得得到一些關(guān)鍵字字母外,用這個(gè)方法我們便可以實(shí)現(xiàn)任意字母的組合。而作者封裝的nb.js也是基于這兩者來實(shí)現(xiàn)輸出黑魔法字符串的。
那么現(xiàn)在的問題是如果通過字符串來執(zhí)行unescape("%77")這段代碼?
來看下hello world那段代碼是如何實(shí)現(xiàn)的:
在這里也不繞彎子了,作者打印了很多次之后才發(fā)現(xiàn)是如此調(diào)用的:
[]["sort"]["constructor"]("return unescape")
因?yàn)镴S調(diào)用方法不光是“.”調(diào)用,通過[]也是可以調(diào)用的。同時(shí)通過return unescape,返回了一個(gè)匿名函數(shù)形成了閉包。故調(diào)用的時(shí)候采用如下方式:
[]["sort"]["constructor"]("return unescape")()("%77") => "w"
至于為什么這段代碼寫出來如此長是因?yàn)樯厦娴拿恳粋€(gè)字母都是一點(diǎn)點(diǎn)拼出來的,也行好上面通過關(guān)鍵字的方式可以得到這些字母=。=不然的話——
封裝nb.js所以經(jīng)過上面的分析你會(huì)發(fā)現(xiàn),除了字符串長度感人之外,這種通過拼接字符串可以返回函數(shù)并且執(zhí)行的方式還真是蠻炫酷的。為了達(dá)到裝逼的效果。作者決定封裝一個(gè)支持字母和數(shù)字的函數(shù),當(dāng)你傳入普通的字符串之后,會(huì)返回帶有黑魔法氣息的冗長字符串,盡情拿去裝x吧,不客氣~
封裝過程 維護(hù)基礎(chǔ)對象與ascll表對象var baseAlibrary = { "a": "[[[] == []][0]+[]][0][1]", "b": null, "c": "[[][[[][0] + []][0][4]+[[][0] + []][0][5]+[[][0] + []][0][1]+[[][0] + []][0][2]]+[]][0][3]", "d": "([][[]]+[])[+!![]+!![]]", "e": "([][[]]+[])[+!![]+!![]+!![]]", "f": "([][[]]+[])[+!![]+!![]+!![]+!![]]", "g": null, ... "0": "(+![])", "1": "(+!![])", "2": "(+!![]+!![])", ... ",": null, "!": null, } var ascll = { //ascll表可自行配置, 新添加后需要在上面對象中配置相同key,只是value為null "A": "41", "B": "42", ... }
將簡單的字母轉(zhuǎn)換方式直接存儲(chǔ)下來,如果需要的字符無法從基礎(chǔ)對象獲取,就記為null,并在ascll表中寫入相關(guān)轉(zhuǎn)碼方式。
封裝unesacpevar result = "" var unescapeStr = "[][(![]+[])[!+[]+!![]+!![]]+([]+{})[+!![]]+(!![]+[])[+!![]]+(!![]+[])[+[]]][([]+{})[!+[]+!![]+!![]+!![]+!![]]+([]+{})[+!![]]+([][[]]+[])[+!![]]+(![]+[])[!+[]+!![]+!![]]+(!![]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+[]]+([]+{})[!+[]+!![]+!![]+!![]+!![]]+(!![]+[])[+[]]+([]+{})[+!![]]+(!![]+[])[+!![]]]((!![]+[])[+!![]]+([][[]]+[])[!+[]+!![]+!![]]+(!![]+[])[+[]]+([][[]]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+!![]]+([]+{})[!+[]+!![]+!![]+!![]+!![]+!![]+!![]]+([][[]]+[])[+[]]+([][[]]+[])[+!![]]+([][[]]+[])[!+[]+!![]+!![]]+(![]+[])[!+[]+!![]+!![]]+([]+{})[!+[]+!![]+!![]+!![]+!![]]+(+{}+[])[+!![]]+([]+[][(![]+[])[!+[]+!![]+!![]]+([]+{})[+!![]]+(!![]+[])[+!![]]+(!![]+[])[+[]]][([]+{})[!+[]+!![]+!![]+!![]+!![]]+([]+{})[+!![]]+([][[]]+[])[+!![]]+(![]+[])[!+[]+!![]+!![]]+(!![]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+[]]+([]+{})[!+[]+!![]+!![]+!![]+!![]]+(!![]+[])[+[]]+([]+{})[+!![]]+(!![]+[])[+!![]]]((!![]+[])[+!![]]+([][[]]+[])[!+[]+!![]+!![]]+(!![]+[])[+[]]+([][[]]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+!![]]+([]+{})[!+[]+!![]+!![]+!![]+!![]+!![]+!![]]+(![]+[])[!+[]+!![]]+([]+{})[+!![]]+([]+{})[!+[]+!![]+!![]+!![]+!![]]+(+{}+[])[+!![]]+(!![]+[])[+[]]+([][[]]+[])[!+[]+!![]+!![]+!![]+!![]]+([]+{})[+!![]]+([][[]]+[])[+!![]])())[!+[]+!![]+!![]]+([][[]]+[])[!+[]+!![]+!![]])" //將[]["sort"]["constructor"]("return unescape")的黑魔法形式存儲(chǔ)起來之后直接調(diào)用 function changeAscll(ascllItem) { var ascllResult = "" var middleValue = "" ascll[ascllItem].split("").forEach(function(item) { if(isNaN(item)) { //ascll中遇到字母則需要再次進(jìn)行unescape轉(zhuǎn)碼 var str = "" ascll[item].split("").forEach(function(data) { str += "+[" + baseAlibrary[data] + "]" }) middleValue += "+" + unescapeStr + "()("+ baseAlibrary["%"]+"+" + str.slice(1) + ")" } else { middleValue += "+[" + baseAlibrary[item] + "]" } }) ascllResult += "+" + unescapeStr + "()("+ baseAlibrary["%"]+"+" + middleValue.slice(1) + ")" return ascllResult } function getUnEscape(str) { } strArr.forEach(function(item) { Object.keys(baseAlibrary).forEach(function(obj, i) { if(item.toLocaleLowerCase() === obj) { if(!baseAlibrary[item]) { Object.keys(ascll).forEach(function(ascllItem) { if(obj === ascllItem) { var cbValue = changeAscll(ascllItem).slice(1) result += "+" + cbValue } }) } else { result += "+" + baseAlibrary[obj] } } }) }) console.log(result.slice(1))效果
也就是一開始大家看到的:
作者將函數(shù)綁定在了this上,通過this.reallyNb()即可得到你想要的~
PS:代碼請部署在服務(wù)器中再打開頁面,否則個(gè)別字母通過location方法會(huì)取不到,主要就是t,p。不過這個(gè)問題之后作者會(huì)將其以ascll表的方式存儲(chǔ),就沒有環(huán)境限制了。只是作者嫌棄那樣做打印的字符串太長了~
最后不定時(shí)更新中——
有問題歡迎在issues下交流。
文章版權(quán)歸作者所有,未經(jīng)允許請勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。
轉(zhuǎn)載請注明本文地址:http://systransis.cn/yun/90612.html
摘要:手摸手教你用寫一個(gè)解釋器用來編譯看起來是個(gè)高大上的東西,實(shí)際原理其實(shí)很簡單,無非就是利用對象屬性可以用字符串表示這個(gè)特性來實(shí)現(xiàn)的黑魔法罷了。 手摸手教你用 js 寫一個(gè) js 解釋器 用 js 來 編譯 js 看起來是個(gè)高大上的東西,實(shí)際原理其實(shí)很簡單,無非就是利用 js 對象屬性可以用字符串表示 這個(gè)特性來實(shí)現(xiàn)的黑魔法罷了。之所以看起來那么 深?yuàn)W, 大概是由于網(wǎng)上現(xiàn)有的教程,都是動(dòng)不...
摘要:即是由此我們可以輕松偽造一個(gè)實(shí)例對象可是這是對對象的屬性的修改,和有什么關(guān)系靜態(tài)方法的繼承少年,可別忘了函數(shù)本身也是個(gè)對象喲在上面的代碼中,我們使無關(guān)對象的指向構(gòu)造函數(shù)的,于是使被判定為的實(shí)例。 關(guān)于 __proto__ 屬性,MDN 上的解釋是這樣的[1]: The __proto__ property of Object.prototype is an accessor prope...
摘要:魔法完整代碼如下今日瞎選篇以上代碼運(yùn)行效果和之前一摸一樣這里就不一一截圖費(fèi)大家流量啦良心前端。。。。對這個(gè)屬性不熟悉的朋友可以去看的文檔幾種語法如下我們用的這個(gè)長度單位實(shí)際應(yīng)用較少,卻是行內(nèi)元素垂直對齊的黑魔法。 showImg(https://segmentfault.com/img/bVbhrMS?w=2936&h=1152); 本文和以前的文章類似,orange 盡量帶給大家分享...
摘要:每個(gè)項(xiàng)目都是從開始的,此項(xiàng)目也不例外??刂破鳛閹砩ψ鳛槠浜诵?,的目標(biāo)是自動(dòng)將元素連接到對象。檢查是否生效刷新頁面,你會(huì)看到任何改變都沒有。在中,處理事件的控制器方法叫做操作方法。這意味這我們擁有了標(biāo)準(zhǔn)的重構(gòu)技術(shù)兵工廠。 學(xué)習(xí) Stimulus 的最簡單方式就是構(gòu)建一個(gè)簡單的控制器。這一章我們就來學(xué)習(xí)一個(gè)。 先決條件 要往下繼續(xù),你需要運(yùn)行一個(gè) stimulus-starter ,...
摘要:之前人家寫過的彈出層,富文本編輯器,語法高亮插件你一套也不能少,這樣你才能接觸到之前碰不到的原生與知識(shí)點(diǎn)。通過引入雙向綁定與分層架構(gòu),完全脫離進(jìn)行前端開發(fā)。 原文:http://www.cnblogs.com/rubylouvre/p/3658441.html 作者:司徒正美 偶的《javascript框架設(shè)計(jì)》終于出版 歷時(shí)兩年多,我的書終于付梓出版了。應(yīng)各方面的要求,寫軟文一篇...
閱讀 1896·2021-11-11 16:55
閱讀 2105·2021-10-08 10:13
閱讀 755·2019-08-30 11:01
閱讀 2166·2019-08-29 13:19
閱讀 3293·2019-08-28 18:18
閱讀 2631·2019-08-26 13:26
閱讀 588·2019-08-26 11:40
閱讀 1879·2019-08-23 17:17