“不学习是相当困难的。”
我正在使用视频中介绍的工具 JSLint 分析他们的代码,这里大约44.00 点。Billiand 的简单版本具有最少的规范(?)错误。视频中提到了一种叫做 ES3.1 的东西即将到来,无论如何我没有资格说它们现在是对还是错——取决于规格(根据视频,当前是 1999 年的规格)。反正我是倾向于用simple-method,反馈一下分析?
大卫托马斯
'document' was used before it was defined.
var liElems = document.getElementsByTagName('li'),
line 2 character 40Missing space between ',' and 'Hej gentlemen '.
strings = ['Hello beautiful lady ','Hej gentlemen '];
line 4 character 6Move 'var' declarations to the top of the function.
for (var i = 0, len = liElems.length; i < len; i++){
line 4 character 6Stopping. (30% scanned).
辉煌
简单的
'document' was used before it was defined.
var lis = document.getElementById("uid").getElementsByTagName("li");
line 2 character 4Missing space between 'for' and '('.
for(var i = 0; i < lis.length; i++)
line 2 character 5Move 'var' declarations to the top of the function.
for(var i = 0; i < lis.length; i++)
line 2 character 5Stopping. (66% scanned).
DOM 版本
'document' was used before it was defined.
var lis = document.getElementById("uid").getElementsByTagName("li");
line 2 character 4Missing space between 'for' and '('.
for(var i = 0; i < lis.length; i++) { // Loop through all <li> elements
line 2 character 5Move 'var' declarations to the top of the function.
for(var i = 0; i < lis.length; i++) { // Loop through all <li> elements
line 2 character 5Stopping. (12% scanned).
丹普
Unexpected dangling '_' in '__elems'.
__elems: false,
line 4 character 17Expected exactly one space between 'function' and '('.
go: function(){
line 4 character 19Expected exactly one space between ')' and '{'.
go: function(){
line 4 character 19Missing space between ')' and '{'.
go: function(){
line 5 character 9Missing 'use strict' statement.
this.__elems = document.querySelectorAll('li');
line 5 character 14Unexpected dangling '_' in '__elems'.
this.__elems = document.querySelectorAll('li');
line 5 character 24'document' was used before it was defined.
this.__elems = document.querySelectorAll('li');
line 6 character 12Missing space between 'for' and '('.
for(var i = 0; i < this.__elems.length; i++){
line 6 character 13Move 'var' declarations to the top of the function.
for(var i = 0; i < this.__elems.length; i++){
line 6 character 13Stopping. (46% scanned).
undefined
document 'go' 4
柠檬
'document' was used before it was defined.
var list = document.getElementById('uids'), // get the parent ul
line 3 character 45Expected exactly one space between 'function' and '('.
Array.prototype.forEach.call(items, function(item) { // because nodeLists are not arrays we do this for a forEach
line 4 character 5Missing 'use strict' statement.
var value = item.textContent || item.innerText; // gets the text content cross browser
line 5 character 10Expected exactly one space between 'while' and '('.
while(item.hasChildNodes()){ // this just removes the contents of the li without innerHTML, and is faster for this amount of data
line 5 character 32Expected exactly one space between ')' and '{'.
while(item.hasChildNodes()){ // this just removes the contents of the li without innerHTML, and is faster for this amount of data
line 5 character 32Missing space between ')' and '{'.
while(item.hasChildNodes()){ // this just removes the contents of the li without innerHTML, and is faster for this amount of data
undefined
document 'items' 3
clear