Share

From this page you can share Javascript Diff Algorithm to a social bookmarking site or email a link to the page.
Social WebE-mail
Enter multiple addresses on separate lines or separate them with commas.
Javascript Diff Algorithm
(Your Name) has forwarded a page to you from Ajaxonomy
(Your Name) thought you would like to see this page from the Ajaxonomy web site.

Javascript Diff Algorithm

Tagged:  

Another tool for your javascript toolbelt!

John Resig implemented a diff algorithm in javascript that includes two functions, one of which is recommended for use:

diffString( String oldFile, String newFile ) This method takes two strings and calculates the differences in each. The final result is the 'newFile' marked up with HTML (to signify both deletions from the oldFile and additions to the newFile).

Sample Code

document.body.innerHTML = diffString(
"The red brown fox jumped over the rolling log.",
"The brown spotted fox leaped over the rolling log"
);

Sample Output

The red brown spotted fox jumped leaped over the rolling log.

Click here to visit the site and download the code!