- 正确性
- 鲁棒性(代码容错能力,特别输入,边界情况等)
- 清晰的书写
- 清晰的布局
- 合理的命名
| /** | |
| * SRouter | |
| * author: dylan<kdylan@qq.com> | |
| */ | |
| (function (window) { | |
| 'use strict' | |
| window.SRouter = { | |
| routers: [], // 路由规则存储 |
| // One pointer | |
| var partition1 = function(array, start, end) { | |
| if(start === end) { | |
| return; | |
| } | |
| // Choose the first element as pivot | |
| var pivot = array[start]; | |
| // last position which is smaller than pivot | |
| var small = start; | |
| for(var index = start + 1; index <= end; index++) { |
题目: 在一个二维数组中,每一行都按照从左到右递增的顺序排序,每一列都按照从上到下的递增的顺序排序。 请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数。
例子: 查找数字7 -> true;查找数字5 -> false。
1 2 8 9
2 4 9 12
4 7 10 13
6 8 11 15
渲染是针对directive来讲的,angularJS内置了很多directive,我们也可以之定义directive,这些directive最终都是通过 $compile service来完成渲染工作的。
$compile service主要分为两个阶段:compile 和 link。
可以通过一下代码理解:
| var events = (function() { | |
| var topics = {}; | |
| return { | |
| publish: function(topic, info) { | |
| console.log('publish a topic:' + topic); | |
| if (topics.hasOwnProperty(topic)) { | |
| topics[topic].forEach(function(handler) { | |
| handler(info ? info : {}); | |
| }) |
| @mixin ellipsis { | |
| overflow: hidden; | |
| text-overflow: ellipsis; | |
| white-space: nowrap; |