您正在查看: 技术研究 分类下的文章
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

js实时动画性能优化初体验

Give it to me I'm worth it Baby I'm worth it Uh huh I'm worth it Gimme gimme I'm worth it Give it to me I'm worth it Baby I'm worth it Uh huh I'm worth it Gimme gimme I'm worth it Okay, I tell her bring it back like she left some Bring it Bring it back like she left some Uh in the club with the lights off What you actin shy fo', come and show me that you wid it, wid it, wid it, wid it, wid it Stop playin', how you know that I wid it, wid it, wid it, wid it, wid it, wid it What you actin shy for Just give me you, just give me you Just give me you, that's all I wanna do And if what they say is true, if its true I might give me to you I may take a lot of stuff Guaranteed I can back it up I think I'ma call you bluff Hurry up, I'm waiting out front Uh huh, you see me in the spot like oooh I love your style Uh huh, show me what you got, cus I don't wanna waste my time Uh huh, you see me in the spot like oooh I love your style Uh huh, show me what you got now come and make it worth my while Give it to me I'm worth it Baby I'm worth it Uh huh I'm worth it Gimme gimme I'm worth it Give it to me I'm worth it Baby I'm worth it Uh huh I'm worth it Gimme gimme I'm worth it It's all on you, it's all on you It's all on you, so what you wanna do And if you don't have a clue, not a clue I'll tell you what to do Come harder just because I don't like it, like it too soft I like it a little rough, not too much, but maybe just enough Uh huh, you see me in the spot like oooh I love your style Uh huh, show me what you got, cus I don't wanna waste my time Uh huh, you see me in the spot like oooh I love your style Uh huh, show me what you got now come and make it worth my while Give it to me I'm worth it Baby I'm worth it Uh huh I'm worth it Gimme gimme I'm worth it Give it to me I'm worth it Baby I'm worth it Uh huh I'm worth it Gimme gimme I'm worth it Okay, I tell her bring it back like she left some Bring it Bring it back like she left some Uh in the club with the lights off What you actin shy fo', come and show me that you wid it, wid it, wid it, wid it, wid it Stop playin', how you know that I wid it, wid it, wid it, wid it, wid it, wid it What you actin shy for Uh huh, you see me in the spot like oooh I love your style Uh huh, show me what you got, cus I don't wanna waste my time Uh huh, you see me in the spot like oooh I love your style Uh huh, show me what you got now come and make it worth my while Give it to me I'm worth it Baby I'm worth it Uh huh I'm worth it Gimme gimme I'm worth it Give it to me I'm worth it Baby I'm worth it Uh huh I'm worth it Gimme gimme I'm worth it 最近研究了一下页面性能优化这一块,参照着这篇文章来实际动手做了一下
原文说的非常好,一路做下来确实很有成就感,页面的性能得到了非常大的提升,实时渲染帧率从原来十几帧提高到了接近60帧。
先嗮一下成果:

icon-plus

javascript 中闭包的概念与用法

夜空中最亮的星 能否听清 那仰望的人 心底的孤独和叹息 夜空中最亮的星 能否记起 曾与我同行 消失在风里的身影 我祈祷拥有一颗透明的心灵 和会流泪的眼睛 给我再去相信的勇气 越过谎言去拥抱你 每当我找不到存在的意义 每当我迷失在黑夜里 夜空中最亮的星 请指引我靠近你 夜空中最亮的星 是否知道 曾与我同行的身影 如今在哪里 夜空中最亮的星 是否在意 是等太阳升起 还是意外先来临 我宁愿所有痛苦都留在心里 也不愿忘记你的眼睛 给我再去相信的勇气 越过谎言去拥抱你 每当我找不到存在的意义 每当我迷失在黑夜里 夜空中最亮的星 请照亮我前行 我祈祷拥有一颗透明的心灵 和会流泪的眼睛 给我再去相信的勇气 越过谎言去拥抱你 每当我找不到存在的意义 每当我迷失在黑夜里 夜空中最亮的星 请照亮我前行 夜空中最亮的星 能否听清 那仰望的人 心底的孤独和叹息 今天咱们来讨论一下 javascript 的这个闭包机制吧
曾经 javascript 的这个闭包的问题困惑了我很久很久
看网上那些说法看了半天都是懵的,看了书更加看不懂
过了好一段时间,在我巩固完一些基础知识之后
现在再回来看这个闭包机制,总算搞懂一些了

首先要弄明白闭包机制,必须对作用域这个东西非常熟悉
JavaScript 中,变量的局部作用域是函数级别的。