Like SystemiConnectFri 15 Oct 2021, 04:50
Auto Save MessagesLGforumFri 26 Feb 2021, 13:31
New tutorial questionTheCrowMon 15 Feb 2021, 08:12
Support iOS Emojis (and other platforms)LGforumSun 14 Feb 2021, 01:25
LGforum (2806)
Store object literal inside function Vote_lcapStore object literal inside function Voting_barStore object literal inside function Vote_rcap 
Mr.Easybb (1587)
Store object literal inside function Vote_lcapStore object literal inside function Voting_barStore object literal inside function Vote_rcap 
Bloodbath (745)
Store object literal inside function Vote_lcapStore object literal inside function Voting_barStore object literal inside function Vote_rcap 
Rukiafan (533)
Store object literal inside function Vote_lcapStore object literal inside function Voting_barStore object literal inside function Vote_rcap 
Dom (513)
Store object literal inside function Vote_lcapStore object literal inside function Voting_barStore object literal inside function Vote_rcap 
puppycheese (446)
Store object literal inside function Vote_lcapStore object literal inside function Voting_barStore object literal inside function Vote_rcap 
pedro (330)
Store object literal inside function Vote_lcapStore object literal inside function Voting_barStore object literal inside function Vote_rcap 
Neymar (301)
Store object literal inside function Vote_lcapStore object literal inside function Voting_barStore object literal inside function Vote_rcap 
Hitsu (281)
Store object literal inside function Vote_lcapStore object literal inside function Voting_barStore object literal inside function Vote_rcap 
Flora (275)
Store object literal inside function Vote_lcapStore object literal inside function Voting_barStore object literal inside function Vote_rcap 


Store object literal inside function

HitsuHitsu
Status : Finished on working fmAPI.

Posts : 281
Join date : 2013-09-09
Age : 25
Location : Indonesia
Sat 22 Aug 2015, 23:54
There are a bunch codes that uses this syntax.

Code:
[panda=js]functionName( {hey: [hello, hi]; } );

I'm wondering how to do that?
HitsuHitsu
Status : Finished on working fmAPI.

Posts : 281
Join date : 2013-09-09
Age : 25
Location : Indonesia
Mon 24 Aug 2015, 09:38
Bump - still need to know a way to implement this.
Mr.EasybbMr.Easybb
Status : Love this site, that's why I'm back each day again... lol Samantha's co-owner now. Well deserved!

Posts : 1587
Join date : 2013-01-04
Mon 24 Aug 2015, 14:22
The code above you posted would return an error. You don't have quotes around your Array values, and you have a semi colon. Here is an implementation I use for creating a new javascript element.

Code:
[panda=js]function create(type, options)
{
    var element = document.createElement(type);
    if(typeof options !== "object")
      return element;

    for(var properties in options)
    {
        if(properties in element)
        {
            element[properties] = options[properties];
        }
        else
        {
            element.setAttribute("data-"+properties,options[properties]);
        }
    }
    return element;
}
//use case

var newDiv = create("div",{
    id:"newDiv",
    className:"google newdivclass",
    attr:"hitsu",
    innerHTML:"Hello World"
});

//this returns the below html

Code:
[panda=html]<div id="newDiv" class="google newdivclass" data-attr="hitsu">Hello World</div>


Sponsored content