您正在查看: 标签 javascript 下的文章
icon-plus

从数组去重来看 javascript 的进化

Semper crescis Aut decrescis Vita detestabilis Nunc obdurat Et tunc curat Ludo mentis aciem Nunc obdurat Et tunc curat Ludo mentis aciem Egestatem Potestatem Dissolvit ut glaciem Divano Divano me Divano messi Divano messia Divano messia Divano Divano me Divano messia Divano messia Sors salutis Et virtutis Michi nunc contraria Est affectus Et defectus Semper in angaria Hac in hora Sine mora Corde pulsum tangite Divano Divano me Divano messi Divano messia Divano messia Divano Divano me Divano messia Divano messia Divano Divano me Divano messia Divano messia In divanooooo Sors salutis Et virtutis Michi nunc contraria Est affectus Et defectus Semper in angaria Hac in hora Sine mora Corde pulsum tangite Divano Divano me Divano messi Divano messia Divano messia Divano Divano me Divano messia Divano messia Hac in hora Sine mora Corde pulsum tangite Quod per sortem Sternit fortem Mecum omnes plangite 说到 javascript 数据去重,估计所有做前端的都并不陌生
数组去重的算法即使在实际生产中不一定用的多,但是在面试中几乎成为了必考的题目
这是一个神奇的题目,看上去好像是死的,应该已经没有什么发挥空间了
但事实上它随着 ECMAScript 标准的发展,数据去重的实现反倒是在不断变化
许多公司甚至可以单从一个数组去重直接看出一个前端工程师的大致水平
今天我也来说说我所知道的 javascript 数组去重吧

icon-plus

从 webpack 1 到 webpack 2 的迁移记

Tryin' to get control Pressure's takin' its toll Stuck in the middle zone I just want you alone My guessing game is strong Way too real to be wrong Caught up in your show Yeah, at least now I know It wasn't love, it wasn't love It was a perfect illusion (Perfect illusion) Mistaken for love, it wasn't love It was a perfect illusion (Perfect illusion) You were a perfect illusion I don't need eyes to see I felt you touchin' me High like amphetamine Maybe you're just a dream That's what it means to crush Now that I'm wakin' up I still feel the blow But at least now I know It wasn't love, it wasn't love It was a perfect illusion (Perfect illusion) Mistaken for love, it wasn't love It was a perfect illusion (Perfect illusion) Where are you? Cause I can't see you It was a perfect illusion But I feel you watchin' me Dilated, falling free In a modern ecstasy Where are you? Cause I can't see you It was a perfect illusion But I feel you watchin' me But I feel you watchin' me Illusion But I feel you watchin' me Mistaken for love Dilated, falling free In a modern ecstasy Mistaken for love In a modern ecstasy In a modern ecstasy I'm over the show Yeah, at least now I know It wasn't love, it wasn't love It was a perfect illusion (Perfect illusion) Mistaken for love, it wasn't love It was a perfect illusion(Perfect illusion) You were a perfect illusion It was a perfect illusion It was a perfect illusion Somewhere in all the confusion It was a perfect illusion, illusion, illusion It was a perfect illusion Somewhere in all the confusion You were so perfect You were a, you were a perfect illusion 最近上手新项目的时候想要用个 sass,结果发现 npm 里面的 sass-loader 默认的 peerDependencies 中的 webpack 版本被升级到了 2
当时没想太多,就装了个 webpack 2.2.1来用,结果发现以前项目的 webpack 配置居然不能够直接用!一跑起来一还堆错
上网查了下,才知道 webpack 2 弄了很多 breaking changes ,想着反正这些问题迟早要解决的,于是就开始了我的 webpack 2 踩坑过程

icon-plus

原生 js 中的各种宽高以及位置的获取

我打电话比你 讲左几句你就收线喇 你变左好多呀 点解唔同我倾落去 点解心不在焉呢 点解对我冷淡 点解 我讲乜野你都反应既呢 从你 你不停的追问 你痴情的态度 令我停停下脚步 还有你追求的心愿 我心曾想配合 但我难照做 这是你爱的控诉 还是爱的追讨 但我始终感觉到 此去没去路 我没有说不爱你 从未说不喜欢 但我心知此刻相爱 时机未到 个个边个黎架 讲左几耐呀 去左几多次街呀 有拖过手呀 点解唔介绍我识 有上过你屋企 有一齐听唱片呀 从你 你不停的追 你痴情的态度 令我停停下脚步 还有你追求的心愿 我心曾想配合但我难照做 这是你爱的控诉 还是爱的追讨 但我始终感觉到 此去没去路 我没有说不爱你 从未说不喜欢 但我不想只讲一句 无可奉告 最近在用原生的js来实现一些交互特效,写的时候发现这些宽度和高度的获取真的是太常用了
而且获取他们的方法不止一个两个,上网一搜发现有好多,看得我眼花缭乱的
于是我自己做了一个归纳,方便以后快速查阅

对于移动端,一般要统一初始化视口宽高缩放比例

icon-plus

利用ajax制作简单的边栏日历插件

追の果てに 静かにeらめく 永hにYる 遥かのs束 かなしみに濡れた ウツセミ コワシテ ~望を 摺り替えて 孤独をでてた ただひとり 君に出会う日まで 此Iへおいで 心重ねよう 君の棘を 取り去ってあげる 崩れ落ちた 未来へ奏でる 叫び声を 拾い上げて 接吻交わそう にY切られ (さえず)る小Bは \を求め 彷徨いAけた 感情を]じる Iナド oイノニ 柔らかな口を するように ただ深く 土に埋もれていた 君の毒に その手の温度に Wの胸は をびてゆく 此Iへおいで すべてが虚(うつろ)に みzまれて れる日も 君を数えたい 叫びを上げるために 今 wび立とう の(うた) Zらうために Wがを失くして 地へ堕ちたなら このを I手で 拾って 「キ 空蝉ヲ 脱ギテタラ 君ハ wベルダロウ 独リデモ」 此Iへおいで 心重ねよう 君の棘を 取り去ってあげる ]を濡らす 大粒の雨を rのを 止めるような 接吻交わそう

这回写了个Typecho边栏日历插件,这是本人第一次写博客插件

链接:https://github.com/istobran/typecho-calender-plugin

在做这个插件的时候,由于是第一次上手玩Typecho插件,遇到了很多很多的问题

先是一点一点的去分析别人写的插件,搞清楚了plugin.php的工作机制,再根据分析结果把自己的代码注入进去

还好自己还有一点这方面的功底,分析过程还算顺利,接着自己写的日历的HTML结构和CSS样式很快就搞定了

在实现日历翻页功能的时候,本来可以用纯javascript去实现的,但是想了想,还是试一下ajax吧

于是就开始着手研究自己从来没接触过的ajax,下面就开始记录一下自己的学习成果

icon-plus

javascript编写正方系统评教脚本

La la, la la la... Hush, don’t speak When you spit your venom, keep it shut I hate it When you hiss and preach About your new messiah ’cause your theories catch fire I can’t find those silver linings I don’t mean to judge But when you read your speech, it’s tiring Enough is enough I’m covering my ears like a kid When your words mean nothing, I go la la la I’m turning off the volume when you speak Cause if my heart can’t stop it, I find a way to block it I go La la, la la la... La la, la la la... I find a way to block it I go La la, la la la... La la, la la la... Yes our love is running out of time I won’t count the hours, rather be a coward When our words collide I’m gonna drown you out before I lose my mind I can’t find those silver linings I don’t mean to judge But when you read your speech, it’s tiring Enough is enough I’m covering my ears like a kid When your words mean nothing, I go la la la I’m turning off the volume when you speak Cause if my heart can’t stop it, I find a way to block it I go La la la la la... La la la la la... I find a way to block it I go La la la la la... La la la la la... I find a way to block you, oh La la la la la... La la la la la... I find a way to block it I go La la la la la... La la la la la... I’m covering my ears like a kid When your words mean nothing, I go la la la I’m turning off the volume when you speak Cause if my heart can’t stop it, I find a way to block it I go I’m covering my ears like a kid When your words mean nothing, I go la la la I’m turning off the volume when you speak Cause if my heart can’t stop it, I find a way to block it I go La la la la la... La la la la la... La la la la la...

之前学校又搞起了评教,觉得每次评教都要鼠标点老半天

实在是不爽,于是想着自己写个快速评教脚本,顺便练习一下久违的javascript

于是动手,用chrome在线调试功能来写

之前只是稍微见过别人调试,没有自己深究过这玩意

现在发现chrome的console还真是挺强大的一个工具

直接按F12,然后切换到console选项卡就可以呼出控制台


于是下意识来个“hello world”,哈哈