var global = ‘‘;
function method() {
var local = ‘‘;
}
//wrong
var arr = [1,2,];
var person = {
name: ‘name‘,
age: 20,
};
//wrong
var arr = [1,2];
var person = {
name: ‘name‘,
age: 20
};
if (!window.inBike) {
window.inBike = {};
}
window.inBike.rideway = rideway;
$(function() {
//bind function is in the init function
window.inBike.rideway.init();
})
var module = function() {
method: function() {
}
};
var str = ‘some text‘;
var obj = null;
var num = 0;
var arr = [];
var isEmpty = true;
if (console) {
console.log(‘this is my log‘);
}
var numberList = [1,2];
var util = {
removeNode: function(){
....
}
};
function Person(name, age) {
this.name = name;
this.age = age;
}
var $image = $(‘#cover‘);
var domImage = document.getElementById(‘cover‘);
var obj = {
_privateVar: null,
method: function() {
}
};
// Handle the case where IE and Opera return items
// by name instead of ID
if ( elem.id !== match[2] ) {
return rootjQuery.find( selector );
}
// Otherwise, we inject the element directly into the jQuery object
this.length = 1;
this[0] = elem;
/**
* @constructor
*/
some.long.namespace.MyClass = function() {
};
/** @enum {string} */
some.long.namespace.Fruit = {
APPLE: ‘a‘,
BANANA: ‘b‘
};
/** @protected */
AA_PublicClass.staticProtectedProp = 31;
/** @private */
AA_PublicClass.prototype.privateMethod_ = function() {};
var $button = $(‘#my-button‘);
$button.click(function(){
var self = this;
var util = {
getVal: function() {
return self.val();
}
}
});
var name = (‘undefined‘ == typeof(name)) ? ‘‘ : name;
(age < 0) && (age = 0);
count++;
// 错误
if (x) {
function foo() {}
}
// 正确
if (x) {
var foo = function() {}
}
原文:http://www.cnblogs.com/qianduanjingying/p/5069254.html