flitbit / diff

Javascript utility for calculating deep difference, capturing changes, and applying changes across objects; for nodejs and the browser.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

diff is not a function

connor11528 opened this issue · comments

I've loaded in the library via a script tag as specified in the readme. I am trying to compare to JSON objects using the diff function. When the user clicks a button I run the compare function:

var diff = new DeepDiff();
var differences = diff.diff(leftObject, rightObject);

This code gives me an error TypeError: diff.diff is not a function. I load in the library with the script tag below:

<script src="https://cdn.jsdelivr.net/npm/deep-diff@1/dist/deep-diff.min.js"></script>

How can I run the diff compare function and why am I getting diff is not a function error?

Solution:

var differences = DeepDiff.diff(leftObject, rightObject);

Example:
https://jsbin.com/qunubunewu/edit?html,js,console