I am confused with the way I write my javascriptand I am wondering what are the differences between? They all generate the same result but which is the best way to write it?
I am using Framer.js
library for prototyping. I do aware Framer.js
uses coffeescriptbut I am writing them in vanilla javascript.
Difference 1
framerOnboard.card1.states.animationOptions({
curve: "spring(200, 20, 0)"
});
framerOnboard.card1.states.animationOptions = {
curve: "spring(200, 20, 0)"
};
Difference 2
framerOnboard.card1.states["switch"]("two");
framerOnboard.card1.states.switch("two");
Difference 1
animationOptions.- It is a function that receives as a parameter an object. This object has a key and this key has a string value.
framerOnboard.card1.states.animationOptions({
curve: "spring(200, 20, 0)"
});
animationOptions.- It is an object with a key and this key has a string value.
framerOnboard.card1.states.animationOptions = {
curve: "spring(200, 20, 0)"
};
Difference 2
There is no difference.
Check this example:
var framerOnboard = {};
framerOnboard.card1 = {};
framerOnboard.card1.states = {};
framerOnboard.card1.states.switch = function(arg) // It's a function.
{
alert(arg);
};
You can execute this functions in two ways:
framerOnboard.card1.states["switch"]("two");
Or
framerOnboard.card1.states.switch("two");