- JSON Formatter/Viewer
Format, minify, visualize and validate JSON.
- JSON Diff
Compare two JSON objects.
- JSON Schema Validator
Validate JSON schema online
- Base64 Encode/Decode
Encode and decode Base64.
- URL Encode/Decode
Encode and decode URL.
- UUID Generator v4 / v1
Generate UUIDs in v4 and other versions.
- Text Hash
Generate cryptographic hashes from your text input using a wide variety of algorithms.
- File Hash
Generate cryptographic hashes from your file using a wide variety of algorithms.
- JWT Decoder & Validator
Decode and validate JSON Web Tokens.
- CSV Viewer
View CSV data in a table.
- CSV to JSON Converter
Convert CSV to JSON.
- JSON to CSV Converter
Convert JSON to CSV.
Bubble Sort JavaScript
This snippet provides a concise guide on how to implement Bubble Sort in JavaScript. It includes code and a step by step explanation.
function bubbleSort(array) {let len = array.length, swap = false; for(let i = 0; i < len; i++) {for(let j = 0; j < len; j++) { if(array[j] > array[j+1]) {let temp = array[j]; array[j] = array[j+1]; array[j+1] = temp; swap = true;} } if(!swap) break; } return array;}
This function takes an array as its parameter. The outer loop will run 'len' times, where 'len' is the length of the array.
Inside the outer loop, another loop will iterate over the array. If it finds any pair where the left element is greater than the right one, it will swap them.
Then it sets the 'swap' flag to true, indicating a successful swap. If no swap occurs on a full pass through the array, the function breaks out of the loop, because the array is already sorted.