Most voted "objects" questions
An object is any entity that can be manipulated by commands in the programming language. An object can be a value, a variable, a function, or a complex data structure. In object-oriented programming, an object refers to an instance of a class.
Learn more…360 questions
Sort by count of
-
51
votes3
answers26529
viewsWhat is the difference between a class and an object?
I was reading a book on object orientation and these two entities are translated differently. What is the difference between the two?
-
38
votes8
answers14487
viewsHow to create a copy of an object in Javascript?
I have an object called cachorro and would like to create and store a copy of that object. As objects, vectors, functions and regular expressions are considered objects I cannot make a copy just by…
-
27
votes4
answers1065
viewsIs there any way to extend an object in javascript?
In PHP, we can usually extend a class using the keyword extends which points to the class that will have inherited methods and attributes. Example: class MyObject extends ArrayObject { } And if I…
-
26
votes5
answers1461
viewsIs it possible to code the size of the object in memory?
If I need to calculate the occupied space to make any decision has how to figure out the size that each type takes to check how much memory will be occupied if I allocate multiple instances of it?…
-
26
votes3
answers3586
viewsIn programming, what is an object?
In programming, it is common to hear the term objeto, often defined in multiple vague definitions, if defined. What is, in fact, an object in programming (not limited to object-oriented…
-
25
votes2
answers1393
viewsWhen should I choose whether or not to use a pointer when creating an object?
In C++, I’m used to seeing objects being created through the operator new, which is when the object is referenced by a pointer, thus: MinhaClasse *mc1 = new MinhaClasse(); This form seems to me the…
-
22
votes2
answers570
viewsWhat is the difference between Object.create or new Object() in Javascript?
I’m going through a technical doubt in Javascript: What’s the difference between Object.create and new Object()? What cases do I have to adopt one over the other?…
-
20
votes3
answers296
viewsWhat are God Objects?
I was reading the documentation of Woocommerce, and I came across the following line: Avoid God Objects God Objects are Objects that know or do Too Much. The point of Object-oriented Programming is…
-
19
votes1
answer25589
viewsWhen should I use __init__ in functions within classes?
For the book I am studying, in some moments the author uses __init__ as a first function of a class. This function (and others) always has self as one of the variables (something I haven’t yet…
-
17
votes2
answers2365
viewsAre JS native objects associative arrays?
And the arrays are like native objects of JS? What about literal strings/primitive data? What I understand is that they are instances of the object string, but with the difference of being arrays…
-
16
votes5
answers51834
viewsIn Javascript, how to verify that an object is empty (without jQuery)?
For jQuery, I can tell if a Object is empty as follows: $.isEmptyObject({}); // true $.isEmptyObject(window); // false To find out if a array is empty, we can do the same, but without jQuery would…
-
16
votes2
answers303
viewsWhat are computed names ("dynamic" structuring) in Javascript?
Reading the documentation of dismantling in Javascript, I found the section below: Computed object property and destructuring names Computed property names, as in literal objects, can be used with…
-
15
votes1
answer193
viewsWhat is the minimum size of an object in memory?
I received an answer in my question that talks about a overhead that the object has. Every object has this overhead? An object without data also has this overhead? Exists object of size 0?…
-
15
votes3
answers356
viewsWhy is it possible to change an array or object value from within a constant?
const array = ["a", "b", "c", "d"]; array[1] = 2; console.log(array); //- ['a',2,'c','d'] In this example I gave, I changed the value of the constant dynamically, too, it is possible to do the same…
-
14
votes2
answers817
viewsHow to create an immutable object in Javascript?
I know it is possible to "freeze" a Javascript object through the method Object.freeze: var x = { foo:"bar", complexo:[1,2,3] }; Object.freeze(x); x.foo = "baz"; // Não tem efeito…
-
14
votes2
answers2102
viewsint and Integer - Java
I’m developing a project in Java and he’s in error, I’ve found it but I don’t understand it. public class Time{ private String nome; private ArrayList<Jogador> jogadores; private Integer gols;…
-
14
votes1
answer1711
viewsIs there a pointer in Javascript?
I was programming and I found something interesting but I was left with doubt in a situation. I created an object and referenced it so: a = {a:1,b:2} And then I created another object and assigned…
-
13
votes2
answers477
viewsJava Performance of methods-filled and empty classes
If I create a class whose goal is to group a number of related methods. Suppose a Class Boi{} and it has several methods but no element. For example: public class Ruminante{ public String…
-
13
votes1
answer1093
views -
12
votes2
answers482
viewsWhat would be the "identity" of an object?
Reading more about objects, trying to "detach" me from the concept that object would only be provided with a "class", in this answer, I saw the following sentence: "Objects have identity. A variable…
-
11
votes2
answers4107
viewsConcept of class, entity and objects
I’m reading about classes in C#, and an excerpt left me a little confused. I know that classes are objects in C#, and can be used in various ways. My doubt is in the following sentence: "A class can…
-
11
votes1
answer282
viewsAre all Javascript values, except primitives, objects?
The documentation at w3school says All Javascript values, except primitives, are objects, which are they: string number boolean null undefined So let nome = 'João'; It’s primitive string type, and…
-
10
votes2
answers6412
viewsWhat is the C++ copy builder for? How do I implement it?
I am a programmer Java and I am currently studying C++. In addition to the "normal" constructors (the standard constructor and the parameterized), C++ has a copy builder. I would like to know what…
-
10
votes3
answers603
viewsWhy is it allowed to delete elements from an array defined as const?
Assuming I have set an array to const: const array = [1,2,3] Why is it possible for one of these elements to be removed? This would not be a way to reassign the array? It’s possible I’ll make one:…
-
10
votes1
answer237
viewsWhat is Prototype Pollution?
I use a tool that performs security checks on the packages of my project, it indicated me that one of the packages is susceptible to Prototype Pollution, would like to know: What exactly is…
-
10
votes4
answers333
viewsHow to manipulate these objects with Javascript?
I have the following objects: { letter: "A", num1: "1", num2: "2", num3: "3" } { letter: "B", num1: "3", num2: "2", num3: "1" } { letter: "C", num1: "2", num2: "3", num3: "1" } I would like to…
-
9
votes2
answers1305
viewsCustomize javascript object comparison
How to determine which value javascript should use for logical operations on objects? I am creating a competency object that needs the following functionalities: Encapsulates the logic of creating a…
-
9
votes1
answer1028
viewsWhat is the maximum number of items I can put inside a List<T> in C#?
I have several questions of performance in my application. What is the maximum number of items I can within my List<T> and what is "acceptable" within good practice.
-
9
votes1
answer144
viewsWhy Arrays and Functions are Objects?
I learned that objects store properties and methods: let objeto = { propriedade: "valor da propriedade", metodo: function() { return "retorno" } } But I see sites calling functions and arrays of…
-
9
votes1
answer941
viewsWhat is the difference between Object.assign and spread Operator?
What is the detailed difference of using Object.assign and the Operator spread (...) for spreading properties of objects? For example, when editing an object for new values, it is the same output:…
-
8
votes2
answers5688
viewsObject Comparison
The code below generates a false, but objects have the same attribute values, there is some method that compares objects, but their attributes, and not the object itself? Produto P5 = new Produto(1,…
-
8
votes1
answer8713
viewsHow to know the "size" (amount of properties/attributes) of an object in Javascript?
Suppose an object as follows: vendas = { obs1:{ Venda1:{Regiao:"Norte", Valor: 200}, Venda2:{Regiao:"Sul", Valor:100} }, obs2:{ Venda1:{Regiao:"Norte", Valor: 50}, Venda2:{Regiao:"Sul", Valor:20} }…
-
8
votes1
answer122
views -
8
votes1
answer147
viewsWhat is the equivalent of Python’s dir function in Javascript?
I was looking for a javascript function equivalent to the function dir python. In Python, if I want to see all methods associated with a given object, just pass the function dir directly to…
-
7
votes3
answers161
viewsAre objects similar to arrays?
Objects are arrays in Javasscript? I have difficulty understanding how this is possible: var obj = { title: 'some value' } console.log(obj['title']); // some value In my conception the use of square…
-
7
votes3
answers2700
viewsJS - Object array for array arrays
How do I convert an array of objects to an array of arrays in javascript? I did so, but returns an array of objects var items1 = new Array(); $.map(objResposta, function(value,index) { teste = new…
-
7
votes3
answers566
viewsSame types but with different objects. What is the best way to use it?
I had to create a new object but totally the same as the one in the C#system. Since the objects are the same I tried to do: ObjetoOriginal.Propriedades = ObjetoClone.Propriedades; Unfortunately it…
-
7
votes1
answer88
viewsWhat is the advantage of PHP objects being passed by default references?
From PHP 5 an object variable no longer contains the object itself as a value. It contains an object identifier that allows the object’s "accessors" to find the real object. I recently went through…
-
6
votes1
answer609
viewsAccess values within an array from the index
I have a variable x with the following content inside: x = [ { id: '1', name: 'name, } ] And I thought to access the id were x.id, however, it is not so. How to access?…
-
6
votes2
answers322
viewsWhy can’t I use $this within a Static class?
As an example below, I was wondering why I can’t use $this within a Static class? <?php class A{ public static function hello(){ echo 'hello'; } } class B extends A{ public function ok(){ echo…
-
6
votes1
answer71
viewsHow to call an object within the creation of another object
I have a Person class and a Date class, the Person class creates a person the date class creates a date to use as the date of birth in the Person class, how do I create a date without having to use…
-
6
votes2
answers665
viewsWhat is the maximum size of an object in 32 and 64 bits?
Specifically the array can have up to 4 billion elements, I think, and the most common sizes of elements should be 4, 8 or 16 bytes. I ask, what is the maximum size that the object can occupy in…
-
6
votes1
answer348
viewsDifference between constructor and function that returns literal object
What is the practical difference between me creating a construction function in this way: function construtora (nome, sobrenome) { this.nome = nome this.sobrenome = sobrenome } Or in this way:…
javascript function characteristic-language objects builderasked 4 years, 6 months ago Gustavo Paiva 173 -
6
votes1
answer125
viewsDifferences between defining object methods using Arrow Function and Function Expression
About "flammable" methods outside objects, I can say that these three forms below act in the same way within my code? Examples: var barquinho = { pedro: () => { console.log("a"); }, tiago:…
-
6
votes2
answers144
viewsHow does changing the prototype of the String.prototype.toString() method affect this code in Javascript?
I couldn’t understand why the method reverse is applied in the string "abcde" (over-written in toString) and not in "12345". String.prototype.reverse = function() { return…
javascript string characteristic-language objects prototypeasked 3 years, 11 months ago vncsbraga 61 -
6
votes1
answer117
viewsCan I create function parameters like string?
I am trying to delve into functions and in the example of the site MDN Web Docs they have the following example: var math = { 'factit': function factorial(n) { console.log(n) if (n <= 1) { return…
-
6
votes1
answer1809
viewsHow to concatenate object properties with Javascript?
I have two objects in Javascript, with the following data: const objeto1 = { prop1: 'a', prop2: 'b', prop3: 'c' } const objeto2 = { prop4: 'd', prop5: 'e', prop6: 'f' } I wanted to take all these…
-
6
votes3
answers90
viewsGroup array of emails by domain of each email in Javascript
I have an array of emails: emails = [ "[email protected]", "[email protected]", "[email protected]", "[email protected]" ] I am using regular expressions to parse domains, and my intention is to…
-
5
votes2
answers6164
viewsGrab information from object Sender
How does the search for information through the Nder object work and in what situations can I use it, with what types of events? This is to avoid event redundancy. Where can I explore these…
-
5
votes1
answer3509
viewsError when using bindParam: Only variables should be passed by Reference
I’m getting an error when I use the bindParam from the PDO, code: Connectionpdo class: function __construct($dsn, $username = NULL, $password = NULL, $options = NULL) { parent::__construct($dsn,…