-1

How to correctly do something like this in JavaScript ?

var object = 
{
   variable1: "test",
   variable2: "sec test",
   variable3 : variable2
}

Is this correct aproach ?

I have created solution like this but I dont know is this good. I am programming newbie. This is JavaScript using jQuery JavaScript library:

(function($, window, document, undefined){

var sakrijContent = 
{

    container : $("div#content"),
    clickCont : $("div#content").find("h3").first(),
    hideBody: "",

    init: function()
    {

        this.hideBody = this.container.find("ul.lista1").first();
        this.clickCont.on("click", function(){

               sakrijContent.hideBody.slideToggle();
        });
    }





}

   sakrijContent.init();


})(jQuery, window, document);
1

1 Answer 1

0

The simple solution would be:

var var2 = "sec test";
var object = {
   variable1: "test",
   variable2: var2,
   variable3: var2
};
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.