JavaScript standard 代码规范的全文
这是 JavaScript standard 代码规范的全文。
掌握本规范的最好方法是安装并在自己的代码中使用它。
细则
使用两个空格进行缩进。
eslint:
indentfunction hello (name) {console.log('hi', name)}除需要转义的情况外,字符串统一使用单引号。
eslint:
quotesconsole.log('hello there')$("<div class='box'>")不要定义未使用的变量。
eslint:
no-unused-varsfunction myFunction () {var result = something() // ✗ avoid}关键字后面加空格。
eslint:
keyword-spacingif (condition) { ... } // ✓ okif(condition) { ... } // ✗ avoid函数声明时括号与函数名间加空格。
eslint:
space-before-function-parenfunction name (arg) { ... } // ✓ okfunction name(arg) { ... } // ✗ avoidrun(function () { ... }) // ✓ okrun(function() { ... }) // ✗ avoid始终使用
===替代==。
例外:obj == null可以用来检查null || undefined。eslint:
eqeqeqif (name === 'John') // ✓ okif (name == 'John') // ✗ avoidif (name !== 'John') // ✓ okif (name != 'John') // ✗ avoid字符串拼接操作符 (Infix operators) 之间要留空格。
eslint:
space-infix-ops// ✓ okvar x = 2var message = 'hello, ' + name + '!'// ✗ avoidvar x=2var message = 'hello, '+name+'!'逗号后面加空格。
eslint:
comma-spacing// ✓ okvar list = [1, 2, 3, 4]function greet (name, options) { ... }// ✗ avoidvar list = [1,2,3,4]function greet (name,options) { ... }else 关键字要与花括号保持在同一行。
eslint:
brace-style// ✓ okif (condition) {// ...} else {// ...}// ✗ avoidif (condition){// ...}else{// ...}多行 if 语句的的括号不能省。
eslint:
curly// ✓ okif (options.quiet !== true) console.log('done')// ✓ okif (options.quiet !== true) {console.log('done')}// ✗ avoidif (options.quiet !== true)console.log('done')不要丢掉异常处理中
err参数。eslint:
handle-callback-err// ✓ okrun(function (err) {if (err) throw errwindow.alert('done')})// ✗ avoidrun(function (err) {window.alert('done')})使用浏览器全局变量时加上
window.前缀。
Exceptions are:document,consoleandnavigator.eslint:
no-undefwindow.alert('hi') // ✓ ok不允许有连续多行空行。
eslint:
no-multiple-empty-lines// ✓ okvar value = 'hello world'console.log(value)// ✗ avoidvar value = 'hello world'console.log(value)对于三元运算符
?和:与他们所负责的代码处于同一行eslint:
operator-linebreak// ✓ okvar location = env.development ? 'localhost' : 'www.api.com'// ✓ okvar location = env.development? 'localhost': 'www.api.com'// ✗ avoidvar location = env.development ?'localhost' :'www.api.com'每个 var 关键字单独声明一个变量。
eslint:
one-var// ✓ okvar silent = truevar verbose = true// ✗ avoidvar silent = true, verbose = true// ✗ avoidvar silent = true,verbose = true条件语句中赋值语句使用括号包起来。这样使得代码更加清晰可读,而不会认为是将条件判断语句的全等号(
===)错写成了等号(=)。eslint:
no-cond-assign// ✓ okwhile ((m = text.match(expr))) {// ...}// ✗ avoidwhile (m = text.match(expr)) {// ...}单行代码块两边加空格。
eslint:
block-spacingfunction foo () {return true} // ✗ avoidfunction foo () { return true } // ✓ ok对于变量和函数名统一使用驼峰命名法。
eslint:
camelcasefunction my_function () { } // ✗ avoidfunction myFunction () { } // ✓ okvar my_var = 'hello' // ✗ avoidvar myVar = 'hello' // ✓ ok不允许有多余的行末逗号。
eslint:
comma-danglevar obj = {message: 'hello', // ✗ avoid}始终将逗号置于行末。
eslint:
comma-stylevar obj = {foo: 'foo',bar: 'bar' // ✗ avoid}var obj = {foo: 'foo',bar: 'bar' // ✓ ok}点号操作符须与属性需在同一行。
eslint:
dot-locationconsole.log('hello') // ✗ avoidconsole.log('hello') // ✓ ok文件末尾留一空行。
eslint:
eol-last函数调用时标识符与括号间不留间隔。
eslint:
func-call-spacingconsole.log ('hello') // ✗ avoidconsole.log('hello') // ✓ ok键值对当中冒号与值之间要留空白。
eslint:
key-spacingvar obj = { 'key' : 'value' } // ✗ avoidvar obj = { 'key' :'value' } // ✗ avoidvar obj = { 'key':'value' } // ✗ avoidvar obj = { 'key': 'value' } // ✓ ok构造函数要以大写字母开头。
eslint:
new-capfunction animal () {}var dog = new animal() // ✗ avoidfunction Animal () {}var dog = new Animal() // ✓ ok无参的构造函数调用时要带上括号。
eslint:
new-parensfunction Animal () {}var dog = new Animal // ✗ avoidvar dog = new Animal() // ✓ ok对象中定义了存值器,一定要对应的定义取值器。
eslint:
accessor-pairsvar person = {set name (value) { // ✗ avoidthis._name = value}}var person = {set name (value) {this._name = value},get name () { // ✓ okreturn this._name}}子类的构造器中一定要调用
supereslint:
constructor-superclass Dog {constructor () {super() // ✗ avoid}}class Dog extends Mammal {constructor () {super() // ✓ ok}}使用数组字面量而不是构造器。
eslint:
no-array-constructorvar nums = new Array(1, 2, 3) // ✗ avoidvar nums = [1, 2, 3] // ✓ ok避免使用
arguments.callee和arguments.caller。eslint:
no-callerfunction foo (n) {if (n <= 0) returnarguments.callee(n - 1) // ✗ avoid}function foo (n) {if (n <= 0) returnfoo(n - 1)}避免对类名重新赋值。
eslint:
no-class-assignclass Dog {}Dog = 'Fido' // ✗ avoid避免修改使用
const声明的变量。eslint:
no-const-assignconst score = 100score = 125 // ✗ avoid避免使用常量作为条件表达式的条件(循环语句除外)。
eslint:
no-constant-conditionif (false) { // ✗ avoid// ...}if (x === 0) { // ✓ ok// ...}while (true) { // ✓ ok// ...}正则中不要使用控制符。
eslint:
no-control-regexvar pattern = /\x1f/ // ✗ avoidvar pattern = /\x20/ // ✓ ok不要使用
debugger。eslint:
no-debuggerfunction sum (a, b) {debugger // ✗ avoidreturn a + b}不要对变量使用
delete操作。eslint:
no-delete-varvar namedelete name // ✗ avoid不要定义冗余的函数参数。
eslint:
no-dupe-argsfunction sum (a, b, a) { // ✗ avoid// ...}function sum (a, b, c) { // ✓ ok// ...}类中不要定义冗余的属性。
eslint:
no-dupe-class-membersclass Dog {bark () {}bark () {} // ✗ avoid}对象字面量中不要定义重复的属性。
eslint:
no-dupe-keysvar user = {name: 'Jane Doe',name: 'John Doe' // ✗ avoid}switch语句中不要定义重复的case分支。eslint:
no-duplicate-caseswitch (id) {case 1:// ...case 1: // ✗ avoid}同一模块有多个导入时一次性写完。
eslint:
no-duplicate-importsimport { myFunc1 } from 'module'import { myFunc2 } from 'module' // ✗ avoidimport { myFunc1, myFunc2 } from 'module' // ✓ ok正则中不要使用空字符。
eslint:
no-empty-character-classconst myRegex = /^abc[]/ // ✗ avoidconst myRegex = /^abc[a-z]/ // ✓ ok不要解构空值。
eslint:
no-empty-patternconst { a: {} } = foo // ✗ avoidconst { a: { b } } = foo // ✓ ok不要使用
eval()。eslint:
no-evaleval( "var result = user." + propName ) // ✗ avoidvar result = user[propName] // ✓ okcatch中不要对错误重新赋值。eslint:
no-ex-assigntry {// ...} catch (e) {e = 'new value' // ✗ avoid}try {// ...} catch (e) {const newVal = 'new value' // ✓ ok}不要扩展原生对象。
eslint:
no-extend-nativeObject.prototype.age = 21 // ✗ avoid避免多余的函数上下文绑定。
eslint:
no-extra-bindconst name = function () {getName()}.bind(user) // ✗ avoidconst name = function () {this.getName()}.bind(user) // ✓ ok避免不必要的布尔转换。
eslint:
no-extra-boolean-castconst result = trueif (!!result) { // ✗ avoid// ...}const result = trueif (result) { // ✓ ok// ...}不要使用多余的括号包裹函数。
eslint:
no-extra-parensconst myFunc = (function () { }) // ✗ avoidconst myFunc = function () { } // ✓ okswitch一定要使用break来将条件分支正常中断。eslint:
no-fallthroughswitch (filter) {case 1:doSomething() // ✗ avoidcase 2:doSomethingElse()}switch (filter) {case 1:doSomething()break // ✓ okcase 2:doSomethingElse()}switch (filter) {case 1:doSomething()// fallthrough // ✓ okcase 2:doSomethingElse()}不要省去小数点前面的0。
eslint:
no-floating-decimalconst discount = .5 // ✗ avoidconst discount = 0.5 // ✓ ok避免对声明过的函数重新赋值。
eslint:
no-func-assignfunction myFunc () { }myFunc = myOtherFunc // ✗ avoid不要对全局只读对象重新赋值。
eslint:
no-global-assignwindow = {} // ✗ avoid注意隐式的
eval()。eslint:
no-implied-evalsetTimeout("alert('Hello world')") // ✗ avoidsetTimeout(function () { alert('Hello world') }) // ✓ ok嵌套的代码块中禁止再定义函数。
eslint:
no-inner-declarationsif (authenticated) {function setAuthUser () {} // ✗ avoid}不要向
RegExp构造器传入非法的正则表达式。eslint:
no-invalid-regexpRegExp('[a-z') // ✗ avoidRegExp('[a-z]') // ✓ ok不要使用非法的空白符。
eslint:
no-irregular-whitespacefunction myFunc () /*<NBSP>*/{} // ✗ avoid禁止使用
__iterator__。eslint:
no-iteratorFoo.prototype.__iterator__ = function () {} // ✗ avoid外部变量不要与对象属性重名。
eslint:
no-label-varvar score = 100function game () {score: while (true) { // ✗ avoidscore -= 10if (score > 0) continue scorebreak}}不要使用标签语句。
eslint:
no-labelslabel:while (true) {break label // ✗ avoid}不要书写不必要的嵌套代码块。
eslint:
no-lone-blocksfunction myFunc () {{ // ✗ avoidmyOtherFunc()}}function myFunc () {myOtherFunc() // ✓ ok}不要混合使用空格与制表符作为缩进。
eslint:
no-mixed-spaces-and-tabs除了缩进,不要使用多个空格。
eslint:
no-multi-spacesconst id = 1234 // ✗ avoidconst id = 1234 // ✓ ok不要使用多行字符串。
eslint:
no-multi-strconst message = 'Hello \world' // ✗ avoidnew创建对象实例后需要赋值给变量。eslint:
no-newnew Character() // ✗ avoidconst character = new Character() // ✓ ok禁止使用
Function构造器。eslint:
no-new-funcvar sum = new Function('a', 'b', 'return a + b') // ✗ avoid禁止使用
Object构造器。eslint:
no-new-objectlet config = new Object() // ✗ avoid禁止使用
new require。eslint:
no-new-requireconst myModule = new require('my-module') // ✗ avoid禁止使用
Symbol构造器。eslint:
no-new-symbolconst foo = new Symbol('foo') // ✗ avoid禁止使用原始包装器。
eslint:
no-new-wrappersconst message = new String('hello') // ✗ avoid不要将全局对象的属性作为函数调用。
eslint:
no-obj-callsconst math = Math() // ✗ avoid不要使用八进制字面量。
eslint:
no-octalconst num = 042 // ✗ avoidconst num = '042' // ✓ ok字符串字面量中也不要使用八进制转义字符。
eslint:
no-octal-escapeconst copyright = 'Copyright \251' // ✗ avoid使用
__dirname和__filename时尽量避免使用字符串拼接。eslint:
no-path-concatconst pathToFile = __dirname + '/app.js' // ✗ avoidconst pathToFile = path.join(__dirname, 'app.js') // ✓ ok使用
getPrototypeOf来替代__proto__。eslint:
no-protoconst foo = obj.__proto__ // ✗ avoidconst foo = Object.getPrototypeOf(obj) // ✓ ok不要重复声明变量。
eslint:
no-redeclarelet name = 'John'let name = 'Jane' // ✗ avoidlet name = 'John'name = 'Jane' // ✓ ok正则中避免使用多个空格。
eslint:
no-regex-spacesconst regexp = /test value/ // ✗ avoidconst regexp = /test {3}value/ // ✓ okconst regexp = /test value/ // ✓ okreturn 语句中的赋值必需有括号包裹。
eslint:
no-return-assignfunction sum (a, b) {return result = a + b // ✗ avoid}function sum (a, b) {return (result = a + b) // ✓ ok}避免将变量赋值给自己。
eslint:
no-self-assignname = name // ✗ avoid避免将变量与自己进行比较操作。
esint:
no-self-compareif (score === score) {} // ✗ avoid避免使用逗号操作符。
eslint:
no-sequencesif (doSomething(), !!test) {} // ✗ avoid不要随意更改关键字的值。
eslint:
no-shadow-restricted-nameslet undefined = 'value' // ✗ avoid禁止使用稀疏数组(Sparse arrays)。
eslint:
no-sparse-arrayslet fruits = ['apple',, 'orange'] // ✗ avoid不要使用制表符。
eslint:
no-tabs正确使用 ES6 中的字符串模板。
eslint:
no-template-curly-in-stringconst message = 'Hello ${name}' // ✗ avoidconst message = `Hello ${name}` // ✓ ok使用
this前请确保super()已调用。eslint:
no-this-before-superclass Dog extends Animal {constructor () {this.legs = 4 // ✗ avoidsuper()}}用
throw抛错时,抛出Error对象而不是字符串。eslint:
no-throw-literalthrow 'error' // ✗ avoidthrow new Error('error') // ✓ ok行末不留空格。
eslint:
no-trailing-spaces不要使用
undefined来初始化变量。eslint:
no-undef-initlet name = undefined // ✗ avoidlet namename = 'value' // ✓ ok循环语句中注意更新循环变量。
eslint:
no-unmodified-loop-conditionfor (let i = 0; i < items.length; j++) {...} // ✗ avoidfor (let i = 0; i < items.length; i++) {...} // ✓ ok如果有更好的实现,尽量不要使用三元表达式。
eslint:
no-unneeded-ternarylet score = val ? val : 0 // ✗ avoidlet score = val || 0 // ✓ okreturn,throw,continue和break后不要再跟代码。eslint:
no-unreachablefunction doSomething () {return trueconsole.log('never called') // ✗ avoid}finally代码块中不要再改变程序执行流程。eslint:
no-unsafe-finallytry {// ...} catch (e) {// ...} finally {return 42 // ✗ avoid}关系运算符的左值不要做取反操作。
eslint:
no-unsafe-negationif (!key in obj) {} // ✗ avoid避免不必要的
.call()和.apply()。eslint:
no-useless-callsum.call(null, 1, 2, 3) // ✗ avoid避免使用不必要的计算值作对象属性。
eslint:
no-useless-computed-keyconst user = { ['name']: 'John Doe' } // ✗ avoidconst user = { name: 'John Doe' } // ✓ ok禁止多余的构造器。
eslint:
no-useless-constructorclass Car {constructor () { // ✗ avoid}}禁止不必要的转义。
eslint:
no-useless-escapelet message = 'Hell\o' // ✗ avoidimport, export 和解构操作中,禁止赋值到同名变量。
eslint:
no-useless-renameimport { config as config } from './config' // ✗ avoidimport { config } from './config' // ✓ ok属性前面不要加空格。
eslint:
no-whitespace-before-propertyuser .name // ✗ avoiduser.name // ✓ ok禁止使用
with。eslint:
no-withwith (val) {...} // ✗ avoid对象属性换行时注意统一代码风格。
eslint:
object-property-newlineconst user = {name: 'Jane Doe', age: 30,username: 'jdoe86' // ✗ avoid}const user = { name: 'Jane Doe', age: 30, username: 'jdoe86' } // ✓ okconst user = {name: 'Jane Doe',age: 30,username: 'jdoe86'} // ✓ ok代码块中避免多余留白。
eslint:
padded-blocksif (user) {// ✗ avoidconst name = getName()}if (user) {const name = getName() // ✓ ok}展开运算符与它的表达式间不要留空白。
eslint:
rest-spread-spacingfn(... args) // ✗ avoidfn(...args) // ✓ ok遇到分号时空格要后留前不留。
eslint:
semi-spacingfor (let i = 0 ;i < items.length ;i++) {...} // ✗ avoidfor (let i = 0; i < items.length; i++) {...} // ✓ ok代码块首尾留空格。
eslint:
space-before-blocksif (admin){...} // ✗ avoidif (admin) {...} // ✓ ok圆括号间不留空格。
eslint:
space-in-parensgetName( name ) // ✗ avoidgetName(name) // ✓ ok一元运算符后面跟一个空格。
eslint:
space-unary-opstypeof!admin // ✗ avoidtypeof !admin // ✓ ok注释首尾留空格。
eslint:
spaced-comment//comment // ✗ avoid// comment // ✓ ok/*comment*/ // ✗ avoid/* comment */ // ✓ ok模板字符串中变量前后不加空格。
eslint:
template-curly-spacingconst message = `Hello, ${ name }` // ✗ avoidconst message = `Hello, ${name}` // ✓ ok检查
NaN的正确姿势是使用isNaN()。eslint:
use-isnanif (price === NaN) { } // ✗ avoidif (isNaN(price)) { } // ✓ ok用合法的字符串跟
typeof进行比较操作。eslint:
valid-typeoftypeof name === 'undefimed' // ✗ avoidtypeof name === 'undefined' // ✓ ok自调用匿名函数 (IIFEs) 使用括号包裹。
eslint:
wrap-iifeconst getName = function () { }() // ✗ avoidconst getName = (function () { }()) // ✓ okconst getName = (function () { })() // ✓ okyield *中的*前后都要有空格。eslint:
yield-star-spacingyield* increment() // ✗ avoidyield * increment() // ✓ ok请书写优雅的条件语句(avoid Yoda conditions)。
eslint:
yodaif (42 === age) { } // ✗ avoidif (age === 42) { } // ✓ ok
关于分号
-
eslint:
semiwindow.alert('hi') // ✓ okwindow.alert('hi'); // ✗ avoid 不要使用
(,[, or`等作为一行的开始。在没有分号的情况下代码压缩后会导致报错,而坚持这一规范则可避免出错。eslint:
no-unexpected-multiline// ✓ ok;(function () {window.alert('ok')}())// ✗ avoid(function () {window.alert('ok')}())// ✓ ok;[1, 2, 3].forEach(bar)// ✗ avoid[1, 2, 3].forEach(bar)// ✓ ok;`hello`.indexOf('o')// ✗ avoid`hello`.indexOf('o')备注:上面的写法只能说聪明过头了。
相比更加可读易懂的代码,那些看似投巧的写法是不可取的。
譬如:
;[1, 2, 3].forEach(bar)建议的写法是:
var nums = [1, 2, 3]nums.forEach(bar)
拓展阅读
- An Open Letter to JavaScript Leaders Regarding Semicolons
- JavaScript Semicolon Insertion – Everything you need to know
一个值得观看的视频:
当前主流的代码压缩方案都是基于词法(AST-based)进行的,所以在处理无分号的代码时完全没有压力(何况 JavaScript 中分号本来就不是强制的)。
一段摘抄自 "An Open Letter to JavaScript Leaders Regarding Semicolons" 这篇文章的内容:
[自动化插入分号的做法]是安全可依赖的,而且其产出的代码能够在所有浏览器里很好地运行。 Closure compiler, yuicompressor, packer 还有 jsmin 都能正确地对这样的代码进行压缩处理。并没有任何性能相关的问题。
不得不说,Javascript 社区里的大牛们一直是错误的,并不能教给你最佳实践。真是让人忧伤啊。 我建议先弄清楚 JS 是怎样断句的(还有就是哪些地方看起来断了其实并没有),明白了这个后就可以随心写出漂亮的代码了。
一般来说,
\n表示语句结束,除非:
- 该语句有未闭合的括号, 数组字面量, 对象字面量 或者其他不能正常结束一条语句的情况(譬如,以
.或,结尾)- 该语句是
--或者++(它会将后面的内容进行自增或减)- 该语句是
for(),while(),do,if()或者else并且没有{- 下一行以
[,(,+,*,/,-,,,.或者其他只会单独出现在两块内容间的二元操作符。第一条很容易理解。即使在 JSLint 中,也允许 JSON,构造器的括号中,以及使用
var配合,结尾来声明多个变量等这些情中包含\n。第二条有点奇葩。 我还想不出谁会(除了这里用作讨论外)写出
i\n++\nj这样的代码来,不过,顺便说一下,这种写法最后解析的结果是i; ++j,而不是i++; j。第三条也容易理解。
if (x)\ny()等价于if (x) { y() }。解释器会向下寻找到代码块或一条语句为止。
;是条合法的 JavaScript 语句。所以if(x);等价于if(x){},表示 “如果 x 为真,什么也不做。” 这种写法在循环里面可以看到,就是当条件判断与条件更新是同一个方法的时候。 不常见,但也不至于没听说过吧。第四条就是常见的 “看,说过要加分号!” 的情形。但这些情况可以通过在语句前面加上分号来解决,如果你确定该语句跟前面的没关系的话。举个例子,假如你想这样:
foo();[1,2,3].forEach(bar);那么完全可以这样来写:
foo();[1,2,3].forEach(bar)后者的好处是分号比较瞩目,一旦习惯后便再也不会看到以
(和[开头又不带分号的语句了。
JavaScript standard 代码规范的全文的更多相关文章
- eslint 代码规范
官网:https://github.com/standard/standard/blob/master/docs/RULES-zhcn.md JavaScript Standard Style Eng ...
- JavaScript Standard Style
这是 JavaScript standard 代码规范的全文. 掌握本规范的最好方法是安装并在自己的代码中使用它. https://github.com/standard/standard/blob/ ...
- 作业三:代码规范、代码复审、PSP
一.代码规范 我认为我们编写的代码都需要进行规范的操作,因为如果为了图省事情或者为了减少时间去完成这个编程.在最后检验的时候就会出现一些警告,导致你这次编程的代码出现问题,当出现问题的时候你在回头去检 ...
- 【转】JavaScript常用代码书写规范
javascript 代码规范 代码规范我们应该遵循古老的原则:“能做并不意味着应该做”. 全局命名空间污染 总是将代码包裹在一个立即的函数表达式里面,形成一个独立的模块. 不推荐 1 2 3 var ...
- javascript,jquery代码规范
jquery代码规范 Coding Standards & Best Practices 中文翻译版:jquery编程的标准写法和最佳实践 javascript代码规范 JavaScript编 ...
- JavaScript代码规范和性能整理
性能 Js在性能方面有多要注意的地方: 避免全局查找 Js性能优化最重要的就是注意全局查找,因为作用域的查找是先找局部作用域在没有找到之后在去上一级作用域查找直到全局作用域,所以全局作用域查找的性能消 ...
- JavaScript 代码规范
所有的 JavaScript 项目适用同一种规范. JavaScript 代码规范 代码规范通常包括以下几个方面: 变量和函数的命名规则 空格,缩进,注释的使用规则. 其他常用规范-- 规范的代码可以 ...
- JavaScript常用代码书写规范
javascript 代码规范 代码规范我们应该遵循古老的原则:“能做并不意味着应该做”. 全局命名空间污染 总是将代码包裹在一个立即的函数表达式里面,形成一个独立的模块. 不推荐 , y = ; c ...
- 代码规范(RL-TOC)用更合理的方式写 JavaScript
代码可以改变世界 不规范代码可以毁掉世界 只有先学会写规范的代码,才可以走的更远 编程语言之间有很多编程规范都是通用: 命名 不要用语言不明的缩写,不用担心名字过长,名字一定要让别人知道确切的意思; ...
随机推荐
- HttpClient和HttpURLConnection的使用和区别(上)
转自:点击打开链接 相信很多Android开发者碰到涉及到Http协议的需求时,都和我一样在犹豫是使用HttpClient还是使用HttpURLConnection呢.我在网上也搜索了很多文章,来分析 ...
- Python小白学习之路(九)—【字符串格式化】【百分号方式】【format方式】
写在前面: 最近的事情好像有很多.李咏的离去,让我觉得很突然,仿佛印象中就是主持节目的他,看着他和哈文的爱情,很是感动.离去,没有什么抱怨,只是遗憾. 总会感慨,时光的流逝. 好像真的很快,转眼间,我 ...
- JS:函数柯里化
函数柯里化 柯里化 在计算机科学中,柯里化(Currying)是把接受多个参数的函数变换成接受一个单一参数(最初函数的第一个参数)的函数,并且返回接受余下的参数且返回结果的新函数的技术. 简单来说,就 ...
- linux安装扩展总结
---恢复内容开始--- 1.安装php 模块安装命令. wget http://pear.php.net/go-pear 执行 php go_pear 如果是php7 wget http://pea ...
- PHP 如何 安全配置
配置选项 phpinfo( ) 函数可用于php.ini文件的定位 A.1. allow_url_fopen 选项允许你如同本地文件一样引用远程资源: 我推荐关闭allow_url_fopen选项,除 ...
- jquery插件开发三种方法
1.好像之前看视频记录下来的,不记得了. //类级别插件开发,主要是在jQuery中定义全局方法: //第一种写法 jQuery.myFunc = function(str){ alert(" ...
- arm处理器启动流程分析
2440: 启动方式:nor , nand 地址布局: 启动流程: 开发板在上电后,会从0x0地址处运行. 如果从nor flash启动,则代码要放在nor 的0地址处: 如果从nand flash启 ...
- nlp 总结 分词,词义消歧,词性标注,命名体识别,依存句法分析,语义角色标注
分词 中文分词 (Word Segmentation, WS) 指的是将汉字序列切分成词序列. 因为在汉语中,词是承载语义的最基本的单元.分词是信息检索.文本分类.情感分析等多项中文自然语言处理任务的 ...
- elasticsearch插件安装之--linux下安装及head插件
/** * 系统环境: vm12 下的centos 7.2 * 当前安装版本: elasticsearch-2.4.0.tar.gz */ 安装和学习可参照官方文档: 1, 安装 # 下载, 获取不成 ...
- for循环的3个参数
1.最常用的方法是用来遍历集合 /** **第一个参数:表示循环的初始值,或初始条件,这里是i=0; **第二个参数:是循环的条件,这里是当i小于list的长度时; **第三个参数:每次循环要改变的操 ...