Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6235317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:38:57+00:00 2026-05-24T10:38:57+00:00

im a php guy, right now im learning on making my first plugin heres

  • 0

im a php guy, right now im learning on making my first plugin

heres what im upto

$.plugin.method({ 
    test: 'helloworld'
});

$.plugin.method({ 
    test: 'another helloworld'
})  

heres my function or class ?

// class ?
jquery.plugin = function(){
    // variables
    var test = [];

    // function ?
    var method = function(params){
        test[] = params['test']
    }
    console.log(test)
}

what im expecting

test = ['helloworld','another helloworld']

can we do that in javascript ? am i getting it right ?

thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T10:38:58+00:00Added an answer on May 24, 2026 at 10:38 am

    In your example you made plugin a function, but in the first snippet you are calling $.plugin.method() and not $.plugin().

    You’d have to make plugin an object with a method property:

    (function($) {
    
        // variables
        var test = [];
    
        $.plugin = {
            method: function(params){
                test.push(params['test']);
                console.log(test)
            }
        }
    
    }(jQuery));
    

    The immediate function ensures that test is only visible to $.plugin itself. You cannot access it from the outside. If you want to do that, you have to make it a property of $.plugin:

    $.plugin = {
        test: [],
        method: function(params){
            this.test.push(params['test']);
            console.log(test)
        }
    }
    

    I suggest you first read a JavaScript guide [MDN guide] to learn the basics about functions [MDN guide] and objects [MDN guide].

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm a PHP guy learning some .NET. I am tinkering around with the UpdatePanel
I'm a PHP guy on my first day in Python-land, trying to convert a
I'm a php guy, but I have to do some small project in JSP.
I'm a Ruby on Rails / PHP guy, and my company got me to
This is a nasty one for me... I'm a PHP guy working in Java
PHP has a great function called htmlspecialcharacters() where you pass it a string and
PHP's explode function returns an array of strings split on some provided substring. It
I'm usually a PHP guy but got stuck doing a project in vb.net. I
I'm a newbie php guy. I have 1 string output from Drupal's date module
I am a PHP guy. In PHP I mainly use Doctrine ORM to deal

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.