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 8223193
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T14:36:03+00:00 2026-06-07T14:36:03+00:00

Say I have the following: function Myobj = { name: Julia, birthdate: xxxx, genres:

  • 0

Say I have the following:

function Myobj = {
   name: "Julia",
   birthdate: "xxxx",
   genres: [],
   movies: [{title: "movie1", rating: 5, genre: "Horror"}, {title: "movie2", rating 3, genre: "Comedy"},{title: "movie3", rating 3, genre: "Comedy"}, {title: "movie4", rating 3, genre: "Comedy"}, {title: "movie5", rating 3, genre: "Horror"}]
}

What I want to be able to do is have some function like:

Myobj.prototype.pushMovie(somejson) {
   // code to add somejson to "movies", and add the "genre" to the "genres" array
}

Such that I can go:

obj1 = new Myobj();
obj1.pushMovie({title: "movie1", rating: 5, genre: "Horror"});

Or is it better practice to override the array prototype? If so, is it possible to give a prototype a specific array as opposed to all arrays like:

Myobj.Array.prototype.pushMovie() {
// code to inherit from regular push, and do some operation to add to "genres"
}

I do not know what the syntactically correct or best approach is.

  • 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-06-07T14:36:06+00:00Added an answer on June 7, 2026 at 2:36 pm

    Why not this?

    Myobj.prototype.addMovie(somejson) {
       this.movies.push( somejson );
    }
    Myobj.prototype.addGenre(somejson) {
       this.genres.push( somejson );
    }
    Myobj.prototype.pushMovie = Myobj.prototype.addMovie;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I have the following code: (defn ^{:graph-title Function 1} func-1 [x] (do-something-with x))
Say I have the following function: foo <- function(x, y = min(m)) { m
Let's say we have the following function: foo <- function(x) { line1 <- x
I have the following (pointless) function, in R : say <- function (string){ if(!exists(string)){
Let's say I have the following, very simple block of code: <script> function hasVal(field)
Say I have a function that does the following in Vb.net For i as
Say I have the following function: bool foo (int a); // This method declaration
Say I have the following template function: template <class T> void apply(const vector<complex<T> >&
Say I have the following two Bash scripts: Version #1: #!/bin/bash function bar {
Say I have the following: std::vector<int> myints; and then I have a function that

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.