beer in bottles
club-mate in bottles
milk in bottles
var a = {};
a[{}] = [{}];
a[{}] == [{}]; false
var a = {};
a[{}] = 1;
a[{}] == 1; true
[]==[] false
[]==[]
==[]==
[]==[] true
false == [] true
var X = function() {};
var y = new X();
y.constructor == X; true
var X = function() {};
var y = new X();
X.prototype == y.prototype; false
var X = function() {};
var y = new X();
X.prototype == y.__proto__; true
var X = function() {};
var y = new X();
X.prototype.__proto__ == y.__proto__.__proto__; true
~~7.5 7
3.toString() parse error
3..toString() "3"
'5' + 3 '53' '5' - 3 2
return { id : 1234, title : 'Tony the Pony' }; parse error return { id : 1234, title : 'Tony the Pony' }; { ... } return /* */{ id : 1234, title : 'Tony the Pony' }; { ... }
Do we need a semicolon at the end?
var myFunction = function() { // ... }
Yes, if the next line starts with brackets:
var myFunction = function() { // ... } // insert semicolon here (function () { // ... })();
var simpsons = ['Homer', 'Marge', 'Bart'];
simpsons[42] = 'Dr. Frink';
simpsons.length = ? 43
'' == '0' false 0 == '' true 0 == '0' true false == 'false' false false == '0' true false == undefined false false == null false null == undefined true " \t\r\n" == 0 true
[[2]] == 2 true [2] == "2" true +[2] == -"-2" true -[2] == -"+2" true
o_O()
parseInt('01') 1 parseInt('02') 2 parseInt('03') 3 parseInt('04') 4 parseInt('05') 5 parseInt('06') 6 parseInt('07') 7 parseInt('08') 0 parseInt('09') 0
if (false) {
alert("Hello World!");
won’t be executed
}
[0] == false true
if ([0]) {
alert("Hello World!");
will be executed
}
1 + + 1 2 1 + - + 1 0 1 + - + - + 1 2 1 + - + - + - + 1 0 1 + - + + + - + 1 2 1 + / + + + / + 1 1/ + + + /1 1 + / + / + / + 1 parse error
typeof 1 == ? "number" typeof "2" == ? "string" typeof NaN == ? "number"