- JSTool
- JSON Viewer - formatting removes characeters.
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
[1,2].forEach(function (a, b, c) { | |
console.log('printing: ' + a); | |
}); |
var arr = [1,2], i=0, len=arr.length; | |
for (; i<len; i++) { | |
console.log('printing: ' + arr[i]); | |
} |
// returns 9 | |
parseInt('09', 10); | |
// returns 0! | |
parseInt('09'); |
// no caching of iteration size | |
for (var i=0; i<myArray.length; i++) {} | |
// caching of iteration size - ugly version | |
var length = myArray.length; | |
for (var i=0; i<length; i++) {} | |
// caching of iteration size - nice version | |
for (var i=0, len=myArray.length, i< len; i++) {} |
1 == '1'; // true | |
1 === '1'; // false | |
1 === 1; //true |
Car = { | |
doors: 0, | |
fuel: '', | |
color: '', | |
changeFuel: function (fuel) { | |
fuel === 'petrol' ? Car.fuel = 'petrol' : Car.fuel = 'diesel'; | |
} | |
}; | |
Car.changeColor = function (color) { |
function Car (doors, fuel, color) { | |
this.doors = doors; | |
this.color = color; | |
this.fuel = fuel; | |
this.changeFuel = function () { | |
if (this.fuel === 'petrol') { | |
this.fuel = 'diesel'; | |
} else { |