Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <p>The <b>Double Tilde ( ~~ )</b> is a double bitwise NOT operator often used as a faster / minimalized sub for Math.Floor(). For example:</p> 
<b>~~2 === Math.floor(2);</b><br />
<code id = 'one'>
</code><br />
<code id = 'two'>
<p>Same with <b><u>positive</u></b> decimals:</p>
<b>~~2.5 === Math.floor(2.5);</b><br />
<code id = 'three'>
  Note though that <b>~~</b> does <b><u>NOT</u></b> yield the same results for <b><u>negative</u></b> decimals as Math.Floor() :</p>
<b>~~(-2.5) = -2    while    Math.floor(-2.5) = -3 </b><br />
<code id = 'four'>
**This is because the double tilde removes everything to the right of the decimal. 
</b><br /><br />
  <b>**</b>Another thing to note is that <b>~~</b> will <b><u>always</u></b> return a number. <br>If it cannot be converted to a number, it will return <b>0</b> ( as opposed to <b>NaN</b> ):
~~('k') = 0    while    Math.floor('k') = NaN
<code id = 'five'>


                p {
  margin: 3% 5%;
  line-height: 1.5em;

pre {
  margin-left: 8%;
  line-height: 1.5em;


                var $ = function (id) {
    return document.getElementById(id);
//examples with whole numbers
$('one').innerHTML ="<b>~~2</b> is equal to " +  ~~2 +  " \nand\n<b>Math.floor(2)</b> is equal to " +  Math.floor(2);
console.log(~~2);// ==> 2
console.log(Math.floor(2));// ==> 2

$('two').innerHTML = "<b>~~(-2)</b> is equal to " + ~~(-2) + "\nand\n<b>Math.floor(-2)</b> is equal to " + Math.floor(-2);
console.log(~~(-2));// ==> -2
console.log(Math.floor(-2));// ==> -2

//examples with decimals
$('three').innerHTML = "<b>~~(2.5)</b> is equal to " + ~~(2.5) + "\nand\n<b>Math.floor(2.5)</b> is equal to " + Math.floor(2.5);
console.log(~~(2.5));// ==> 2
console.log(Math.floor(2.5));// ==> 2

$('four').innerHTML = "<b>~~(-2.5)</b> is equal to " + ~~(-2.5) + "\nand\n<b>Math.floor(-2.5)</b> is equal to " + Math.floor(-2.5);
console.log(~~(-2.5));// ==> -2
console.log(Math.floor(-2.5));// ==> -3

$('five').innerHTML = "<b>~~('k')</b> is equal to " + ~~('k') + "\nand\n<b>Math.floor('k')</b> is equal to " + Math.floor('k');
console.log(~~('k')); // ==> 0
console.log(Math.floor('k')); // ==> NaN