自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

意涵团_晴天的博客

愿有岁月可回首,且以深情共白头

  • 博客(52)
  • 收藏
  • 关注

原创 从输入url到页面加载完成发生了什么

从输入url到页面加载完成浏览器从url中解析出服务器的主机名(eg: www.google.com);DNS解析浏览器将主机名转换成HTTP服务器的IP地址,这一步即为DNS解析,具体的解析过程可查看DNS解析过程;浏览器解析端口号,如果没有端口号,则默认80端口;有了IP和端口号,则在客户端和服务器端建立TCP/IP连接;浏览器向服务器发送HTTP请求报文;服务器向浏览器返回一...

2018-11-19 19:05:12 221 1

原创 webpack-loader&plugins&mode

loader  webpack中的loader是一个预处理器,将非js类型的文件转换为 webpack 能够处理的有效模块。   本篇主要介绍如何在webpack.config.js中进行配置。const config = { module: { rules: [ { test: /\.(css|less|sass)$/, loader: ...

2018-04-18 17:23:43 331

原创 webpack-entry&output

  webpack是静态模块打包器,可以递归的构建项目的依赖关系图。有4个重要的概念:entry(入口文件)output(出口文件)loadersplugins(插件)本文首先介绍下entry和output:entry项目的入口文件,webpack中的默认值为’./src’,有2种写法:简写: webpack.config.js//entry: stri...

2018-04-17 12:32:10 501

原创 DNS解析过程

网络通讯一般是基于TCP/IP协议的,TCP/IP基于ip地址,所以计算机在网络间通信时只能识别ip地址而不能识别域名,但是ip地址不好记,我们访问网页的时候都是访问域名,这时候就需要DNS服务器将域名转化成IP地址。 DNS(domain name system)解析过程输入域名之后,首先查找hosts文件,看是否有IP-域名映射,有的话返回ip地址如果hosts里面没有,则查找本地DNS解

2017-08-29 17:01:32 329

原创 react与backbone比较

1.为什么react那么火?在web开发过程中,要将变化的数据渲染到页面上,必然需要对DOM的操作,频繁的DOM操作降低页面性能,而react的核心是虚拟DOM,并没有真实的操作DOM,而是用js构建出新的DOM树(只是一种内存数据),react将当前该DOM树与上一次的DOM树进行对比,得到DOM结构的区别,然后将需要变化的部分进行实际的DOM更新。2.Backbone Backbone帮助我们

2017-08-17 18:11:50 1864

原创 react数据流

1.react数据流以及组件间沟通react是自上而下的单向数据流,从父节点传递到子节点(通过props);如果顶层的props改变,react会重新渲染所有子节点。props:用于组件间状态的传递,用于整个组件树中传递数据和配置,在当前组件访问props使用this.props;state 指的是组件内部的状态,只能从当前组件调用this.setState修改state值,一般更新子组件都是通过改

2017-08-17 17:56:42 273

原创 backbone model和view

1.backbone中model和view 是怎么绑定的view和model一对一 Router里面在routes类定义动作键值对,当匹配到响应的url,执行相应动作显示相应页面,这时候绑定model和view,主要是通过构造函数将model传到view中 new View({model: new Model()}); 绑定之后通过this.model取得model中的各种方法。如果一个v

2017-08-17 17:10:42 754

原创 根据对象属性对数组进行排序

关键在于arr.sort()方法//升序function sortBy(propertyName) { return function(obj1,obj2) { var val1 = obj1.propertyName; var val2 = obj2.propertyName; return val1 - val2; }}var

2017-07-05 15:43:08 340

原创 关于redux

基本原则应用中的state以对象树的形式存储在store中,通过store.getState()可以获取state对象树。state是只读的,只能通过触发一个action来改变state store.dispatch()触发action通过编写reducer来指定state对象树如何通过action进行改变。reducer是纯js函数,以prevState和action为入参,返回新的sta

2017-06-30 10:18:46 241

原创 我理解的虚拟DOM

react中的组件(React.Component的实例)并不是真实的dom节点,是存在于内存中的一种数据结构,叫做虚拟DOM。 组件在呈现的过程中,先根据render返回的结果将这个树状结构(虚拟DOM)在js中创建出来,这个时候并没有操作DOM,然后比对新老虚拟DOM,渲染成实际的DOM。在react的设计中,所有DOM的变动,都现在虚拟DOM上发生,然后将实际发生变动的部分反映在真实的DOM

2017-06-29 14:47:33 673

原创 React props和state的区别

React中通过状态实现dom的渲染,组件状态分为两种:props和state。props props是指组件间的状态传递,由于React是单向数据流(自上而下)的,所以props从父组件传递给子组件。在组件之间通信用 组件内部的this.props属性是只读的,不能修改state state是组件内部的状态,只能通过setState来改变,用来更新组件内部的数据props和state之间

2017-06-29 10:40:11 1500

原创 react-native构建android hello world踩坑记

写在前面: 纯小白,记录自己踩过的坑我傻我承认,有node环境的情况下又装了一遍node导致系统中有2个node版本 卒。。。。 解决方案 :重装nvm。。。辣么傻。。。然后create-react-native-app新建项目报错 原因:项目中设置项目 npm set registry=http://registry.npm.mycompany/,这样设置会报错,,我也不知道为啥。。 解

2017-06-21 17:47:31 538

原创 MVC && MVP && MVVM

MVC 用户操作界面,view传送指令到controller,controller完成业务逻辑之后要求model改变状态,model改变之后通知view刷新 用户直接更改url,controller完成业务逻辑之后通知model改变状态,然后model要求view重新渲染。 backbone中的MVC 用户可以给view发送指令(click事件),view要求model改变状态,vi

2017-05-04 17:27:37 306

原创 记我的头条面经

三面卒。。。。。 一面 上来先做笔试,3个题ABCDE五个学校参加竞赛,其中已知 E不是第二或者是第三;下面是几个学校的预测。A: E是第一 B: 我是第二 ; C : A最差 D: C不是最好 E:D是第一 其中只有真实排名为1 2 的学校说的是真话,其余人说的都是假话。给一个无序不重复的数组,找出n个数字,和为m画一个自适应正方形,其中宽度是屏幕宽度的50%,要求水平垂直居中。做完题

2017-04-27 18:46:14 776

原创 反转数字

eg:输入123 输出321function reverseNum(n) { var res = 0; while(n > 0) { var m = n % 10; res = res * 10 + m; n = parseInt(n / 10) } return res}

2017-04-24 18:50:19 242

原创 我的面经1

jsfunction test(){ for(var i = 0; i < 3; i++) { var img = document.createElement('img'); img.src = 'img' + i + '.png'; img.onload = function(){ alert(i...

2017-04-22 12:33:39 273

原创 Find Minimum in Rotated Sorted Array II

Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).Find the minimum element.The array may contain duplicates.

2017-04-20 15:08:04 264

原创 Find Minimum in Rotated Sorted Array

Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).Find the minimum element.You may assume no duplicate exist

2017-04-20 14:53:57 415

原创 495. Teemo Attacking

In LLP world, there is a hero called Teemo and his attacking can make his enemy Ashe be in poisoned condition. Now, given the Teemo’s attacking ascending time series towards Ashe and the poisoning time

2017-04-20 14:07:51 229

原创 118. Pascal's Triangle

Given numRows, generate the first numRows of Pascal’s triangle.For example, given numRows = 5, Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1] ]var generate = function(n) {

2017-04-20 11:42:24 205

原创 动态规划入门-Triangle

动归解题的一般思路:将原问题分解成多个子问题。子问题都解决了,原问题就解决了用动态规划解题时,我们往往将和子问题相关的各个变量的一组取值,称之为一个“状态”。一个“状态”对应于一个或多个子问题,所谓某个“状态”下的“值”,就是这个“状态”所对应的子问题的解确定初始状态确定状态转移方程eg:leetcode120. Triangle Given a triangle, find the mi

2017-04-20 10:13:39 330

原创 Isomorphic Strings

Given two strings s and t, determine if they are isomorphic.Two strings are isomorphic if the characters in s can be replaced to get t.All occurrences of a character must be replaced with another chara

2017-04-19 19:18:01 187

原创 Best Time to Buy and Sell Stock

Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock), desi

2017-04-18 16:00:14 182

原创 Reverse String II

Given a string and an integer k, you need to reverse the first k characters for every 2k characters counting from the start of the string. If there are less than k characters left, reverse all of them.

2017-04-18 15:43:48 220

原创 Ransom Note

Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if the ransom note can be constructed from the magazines ; ot

2017-04-13 15:48:32 182

原创 Relative Ranks

Given scores of N athletes, find their relative ranks and the people with the top three highest scores, who will be awarded medals: “Gold Medal”, “Silver Medal” and “Bronze Medal”.var findRelativeRanks

2017-04-12 11:58:27 239

原创 Assign Cookies

Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie. Each child i has a greed factor gi, which is the minimum size of a cook

2017-04-12 11:57:32 276

原创 Construct the Rectangle

For a web developer, it is very important to know how to design a web page’s size. So, given a specific rectangular web page’s area, your job by now is to design a rectangular web page, whose length L

2017-04-07 10:30:57 242

原创 Next Greater Element I

You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of nums2. Find all the next greater numbers for nums1’s elements in the corresponding places of nums2.The

2017-04-06 19:10:18 241

原创 Add Digits

Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.For example:Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has only one digit, r

2017-04-06 16:34:32 325

原创 Plus One

Given a non-negative integer represented as a non-empty array of digits, plus one to the integer.You may assume the integer do not contain any leading zero, except the number 0 itself.The digits are st

2017-04-06 15:08:01 259

原创 Excel Sheet Column Title

Given a positive integer, return its corresponding column title as appear in an Excel sheet. For example:1 -> A2 -> B3 -> C...26 -> Z27 -> AA28 -> AB var convertToTitle = function(n) { var

2017-04-06 14:29:40 450

原创 Count Primes

Count the number of prime numbers less than a non-negative number, n.var countPrimes = function(n) { var arr= []; for(var m = 0; m < n; m++) { arr[m] = true } for(var i = 2; i <

2017-04-06 11:49:53 239

原创 Perfect Number

We define the Perfect Number is a positive integer that is equal to the sum of all its positive divisors except itself.Now, given an integer n, write a function that returns true when it is a perfect n

2017-04-06 10:56:09 274

原创 Word Pattern

Given a pattern and a string str, find if str follows the same pattern. Examples: pattern = “abba”, str = “dog cat cat dog” should return true. pattern = “abba”, str = “dog cat cat fish” should retu

2017-04-06 10:35:59 245

原创 Valid Palindrome

Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. For example, “A man, a plan, a canal: Panama” is a palindrome. “race a car” is not a pal

2017-03-27 10:22:52 210

原创 求两个字符串最长公共子串的长度

function maxCharLen(s1,s2) { var res = 0; for(var i = 0; i < s1.length; i++) { if(s2.indexOf(s1.charAt(i)) != -1) { var len = 0, m = i, n = s2.indexOf(s1.charAt(i)); while

2017-03-24 14:41:12 491

原创 K-diff Pairs in an Array

Given an array of integers and an integer k, you need to find the number of unique k-diff pairs in the array. Here a k-diff pair is defined as an integer pair (i, j), where i and j are both numbers in

2017-03-22 16:20:33 275

原创 merge sorted array

Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.function merge(nums1,m,nums2,n) { var i = 0, j = 0, flag = 0; var cnum = []; for (var k = 0

2017-03-22 16:08:27 188

原创 js数组求交集

//交集function intersect(arr1, arr2) { var res = []; for(var i = 0; i < arr1.length; i++){ for(var j = 0; j < arr2.length; j++){ if(arr1[i] == arr2[j]){ res.push(arr1[i])

2017-03-22 15:34:40 473

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除