前端在变,框架在变,但有个东西永远都不会过时,那就是掌握了javascript,才能更好掌控未来
用原生js实现bind方法
返回一个永远指向传入对象的函数
Function.prototype.bind = function(context) {
var self = this;
return function() {
return self.apply(context, arguments);
}
};
用原生实现继承的方法
var a = {a: 1};
var b = Object.create(a);
Object.create = function(o) {
var Fun = function() {};
Fun.prototype = o;
return new Fun();
}
FEATURED TAGS
前端开发
H5
JavaScript
设计模式
browser
jQuery
源码分析
生活
leetcode
Array
Stack
Queue
Linked List
剑指offer
Binary Search Tree
Binary Tree
Breadth-First Search
Depth-First Search
String
Set
Binary Search
Sliding Window
Backtracking
Dynamic Programming
Two Pointers
Union Find
Sort
Bit Operation
Recursion
Map
Graph
Search
Hash
LinkedList
复盘
QuickSort
Trie
Design
MinHeap
Traverse
Min Heap
Node.js
BackEnd
SQL
MySQL
Design Patterns
Network
计算机网络
Python
SVG