Hey all, I've been fiddling with JavaScript and decided to share a neat little thing (its completely useless). Finished Code Code: console.log(+[[-~[]<<~[]][+[]]+[]][+[]][++[[]][+[]]+[+[]]]); //Prints 8 Now for the break down - Pre-note - I use this function while playing with variables. It outputs the value and type of a variable. (The counter is to force the developer console to display each seperately) Code: var counter = 0; ...
console.log(+[[-~[]<<~[]][+[]]+[]][+[]][++[[]][+[]]+[+[]]]); //Prints 8
var counter = 0;
I'm amazed at how many people don't use a very simple shortcut for document.getElementById. This is for all the people who don't use a javascript library like jQuery. All you have to do is include this code somewhere on your page Code: function $(element) { return document.getElementById(element); } Then when you want to use document.getElementById('id'); just type $('id'); instead. Example Code: <html> ...
function $(element) { return document.getElementById(element); }
document.getElementById('id');
<html>