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
-
5
votes2
answers83
viewsWhat is the syncblock?
I received a reply about a syncblock. Why is it necessary? I understand what I researched is about competition control. But why does every object need it if not everyone will have competition?…
-
5
votes4
answers197
viewsCorrect syntax way in object instance
In the instance of an object, we can: Pessoa pessoa = new Pessoa(); and we can also: Pessoa pessoa = new Pessoa(){ Nome = "Nome", Id = 0, Situacao = true }; What is the best or most correct way to…
-
5
votes2
answers1771
viewsLogic for grouping data in javascript array
I’m having trouble grouping some data using the Javascript. I have the following array of objects that return from database and shipping to the view: var object = [ { data: 1, categories: "Branca",…
-
5
votes1
answer78
viewsType Object in PHP
I’m practicing some code in PHP when I come across this: <?php $a = (object) ["a" => "b"]; $b = (object) ["a" => "c"]; $y = $a <=> $b; echo $y; $v=[1,2,3] <=> [1,2,3]; echo $v;…
-
5
votes2
answers61
viewsWhat is the definition of delete in Javascript?
I came across an instruction that delete represents a type in Javascript. At least that’s what I understood. I’d like your help because I couldn’t find any references on the Internet. if…
javascript characteristic-language objects operators deleteasked 4 years, 6 months ago Willian Andrade 53 -
5
votes2
answers237
viewsAccess Javascript properties: point notation or square brackets?
Let’s say we have an object called rectangulo and a property called area. We can access this property in the following ways: Point notation: rectangulo.area. Bracket notation: rectangulo['area']. I…
javascript characteristic-language objects propertyasked 4 years, 4 months ago Tiago Martins Peres 李大仁 236 -
5
votes1
answer62
viewsCopied objects stay at different addresses?
When I have for example: $abc = new ZZZ(); $mno = $abc; The object $mno is the same as $abc? That is, do they have "memory addresses" alike? How do I print this "memory address"?…
-
5
votes1
answer185
viewsWhat is the difference between creating an object from the literal form or from a constructor function?
I wonder if it has any difference or relevance between the two forms below in the construction of an object: Create an object from the literal form: let pessoa = { nome: 'Pedro' };…
javascript characteristic-language objects builder prototypeasked 4 years, 7 months ago felipe cardozo 275 -
5
votes1
answer111
viewsSet does not remove duplicate objects
I have an array of objects and always to remove duplicate objects use the new Set(array), but this time did not work as expected. In the following example, it is easier to understand. I’m passing my…
-
5
votes2
answers86
viewsIs there a difference in creating objects and adding properties with literal notation or with`new Object` in Javascript?
I have a question. Do this here: let meuCarro = new Object(); meuCarro.fabricacao = 'Ford'; meuCarro.modelo = 'Mustang'; meuCarro.ano = 1969; console.log(meuCarro.fabricacao);…
-
4
votes2
answers178
viewsHow do I get the values of a date in the "dd/MM/yyyy hh:mm" format and compare it to the system date after setting it in this same format?
I wanted to make a comparison between the date contained in the hora1 object and the system date, as I can do? import java.text.SimpleDateFormat; import java.util.Date; public class MainTarefas {…
-
4
votes1
answer124
viewsIs it recommended to use prototype on native objects?
I think it’s great to have my own methods imported into the Javascript native objects. For example: String.prototype.hello = function(){ return this.toString() + ' hello'; } 'Say '.hello() // say…
-
4
votes2
answers257
viewsRestrict object method override in javascript
I’m trying to create an object where your methods can’t be changed. That is, its value, even if modified, should continue as originally defined. Example: var object = (function(object){…
-
4
votes3
answers3047
viewsUnfulfilled Nfe XML
Well, I’m trying to do the reading for import of XMLs of the Electronic Tax Notes and I’m having a lot of difficulty in disemboweling the ICMS of the blessed. No problems to reach the object ICMS:…
-
4
votes3
answers18966
viewsBrowse objects with pure Javascript
I need to list objects and resort to the following function which is in jQuery. There is an alternative to this only in Javascript? $.each(object, function(index, value) { console.log(value); });…
-
4
votes2
answers1104
viewsShow an object/variable with different names in R?
Considering the following routine: x <- 1:10 for (i in 1:length(x)) { ## Nome da variável: nomevar <- paste0("Var_", i) var <- x[i] + 2 assign(nomevar, var) print(nomevar) # aqui esta minha…
-
4
votes3
answers120
viewsWhat is the syntax of literal objects in Javascript?
Can anyone help me with this structure? I don’t know what it is or how it works. var variavel = { teste1: '1', teste2: '2', teste3: '3' };…
-
4
votes1
answer220
viewsWhy does the expression "$a->b->c->d->e->f->g->h->i->j =& $null;" return several objects within each other, and it doesn’t even exist?
I was doing some tests with value assignments by PHP references and came across a curious example. $a->b->c->d->e->f->g->h->i->j =& $null; Both the variables $a and…
-
4
votes2
answers118
viewsWhy does comparing different objects return true?
First code: Integer i1 = 1234; Integer i2 = 1234; System.out.println(i1 == i2); //false System.out.println(i1.equals(i2)); //true Even though it seems that primitive types are being used, they are…
-
4
votes1
answer1099
viewsHash, Object or Dictionary?
I have been studying python and ruby and have seen that several other languages as well as these two make use of different terminologies to determine a ' Json object. var objeto = { 'name' : 'Darth…
-
4
votes2
answers192
viewsWhy is there no String.Toint() method?
String in C# is an object, right? From what I saw to string is a class, different from int and other primitive types that are simple types, (I’ve seen on another site too, that they are all objects…
-
4
votes5
answers1186
viewsHow to use the reduce (reduce) operation on objects?
In Javascript, when I need to do a reduction operation, I use the method Array.reduce. Thus: var valores = [1, 2, 3, 4, 5, 1000]; var resultado = valores.reduce(function (soma, atual) { return soma…
-
4
votes1
answer129
viewsWhen is the destroyer of an object called in C++?
Let’s assume I have a function: std::string empty_string() { std::string x{ "" }; return x; } As normal as it sounds, it gets a little fuzzy when we think: When the destroyer of the object x is…
-
4
votes1
answer73
viewsAre methods objects in Ruby?
Ruby’s got the class Proc, that is defined in the documentation as Blocks of code that have been bound to a set of local variables. Once bound, the code may be called in Different contexts and still…
-
4
votes1
answer397
viewsJava Priorityqueue Comparator
I’m trying to understand why the native mode of java is not performing the comparison, I don’t know where I’m going wrong. MAIN // EXERCICIO PARA COMPARAR DOIS OBJETOS, USANDO CLASSE NATIVA DE…
-
4
votes3
answers1067
viewsIndex or key in Javascript object
I have this situation: const movies = { 1: { id: 1, name: 'Planet Earth', }, 2: { id: 2, name: 'Selma', }, 3: { id: 3, name: 'Million Dollar Baby', }, What would these numbers be 1, 2 and 3 with two…
-
4
votes1
answer2524
viewsHow to remove an object from an object array within another object array, in javascript?
Hello, I need to return the objs array by eliminating the objects that have the req key === "test" inside the c object array. Thanks for your help! const objs = [ { a: "a", b: 1, c: [ { send:…
-
4
votes1
answer127
viewsWhat are Javascript property descriptors and attributes and how do they work?
Eventually I read, mainly in more advanced content about objects in Javascript, the terms "proprietary descriptors" and "property attributes". I believe they are related concepts. What they are and…
-
4
votes1
answer41
viewsLexically, what happens when we return a variable within a method that is declared in the function of that method?
Someone helps me understand the context of the execution of this code? myVar is declared in Global; myVar is declared in a(); b() is executed and myVar is declared in b(); myVar is not found in c():…
-
4
votes1
answer291
viewsComposition of objects in Python
In this case, I’m trying to understand how the connection between two classes and their objects. Since, when creating an object, a space in memory would be reserved for it, this space includes the…
-
4
votes1
answer76
viewsCreation of objects in Javascript
Let’s say we want to create an object called Retângulo (if desired, with properties such as length, width, perimeter and area). As shown in the next diagram (created based on the information present…
-
4
votes2
answers186
viewsDoubt about Number.isInteger() in JS. Number is an object or function?
Number would be a function or object? My teacher said that everything in Javascript can be seen as a function (even objects) and it confused me a little. He told me that Number would be an…
-
4
votes1
answer77
viewsCan I use Object.assign to assign properties to this in Javascript?
I’m learning about objects now and I’d like to know if it’s possible to use Object.assign to assign all properties to this of a class in Javascript. Example: class Foo { name; email; phone;…
-
4
votes0
answers37
viewsWhat is and what is the exotic Windowproxy object for?
While looking for good links to this answer, I came across a quote from an object called WindowProxy. In the search for explanations, I found this link with the definition: A Windowproxy is an…
-
4
votes1
answer146
viewsWhat is the difference between the "in" operator and the "hasOwnProperty" method in Javascript?
An unexpected behavior (at least for me) occurred with the following excerpt of code that I will demonstrate below: const str = new String('olá SOpt'); console.log('Usando "in"', 'length' in str);…
-
4
votes1
answer47
viewsWhy does the "delete" operator not remove references to a deleted Javascript property?
I am reading a book about data structure in Javascript and came across the following situation: why delete does not delete a reference value? I will give an example to be clear. const items = { a:…
javascript characteristic-language objects operators deleteasked 3 years, 7 months ago Mr Genesis 464 -
4
votes1
answer60
viewsHow do I keep an original copy when using Sort in Javascript arrays?
I need to sort an array, but I can’t miss the original sequence. To do this, I created a new variable and assigned the value to it, making a copy of the original. However, when using the method…
-
3
votes2
answers403
viewsPass list of objects between files
How to pass a list of objects through two Javascript files? I have a list: var elementsList = []; And this list is populated with N objects: var oElement = { elem: "", emin: 0.0000, emax: 0.0000 } I…
-
3
votes1
answer585
viewsHow do I add a different object to a list whenever using the add?
I’m having trouble adding a different object to a list of objects whenever I use her add, I know what the problem is but I don’t know how to fix it, follow the code List class public class Lista {…
-
3
votes5
answers9733
viewsHow to get the index of a javascript object searching for the value?
I have such a JS object (fictitious values): { aifuw : 7, hsjwo : 5, hsgqk : 137, jskwe : 9483, NNNNN... : N... } I need to get the index where the value is 137. The ways I tried didn’t work out.…
-
3
votes3
answers4208
viewsIs it possible to create an object dynamically in JS without using Eval?
I have the following code: Arr = ["meu", "objeto", "dinamico"]; Val = 100; Eval = ""; obj = {}; for(i in Arr){ Eval += "['"+ Arr[i] + "']"; eval("obj"+Eval+"={}") } eval("obj"+Eval+"="+Val); As you…
-
3
votes4
answers15572
viewsWhat is the super() function for;
I am studying Java and I need to understand the logic of a code here. I wanted to know what this piece of code does: public class UsuarioController extends HttpServlet { private DAO dao; public…
-
3
votes2
answers239
viewsHow to place a property name on a Javascript object?
js = { p1: { qq: "qq_val", }, p2: [{ qq: "qq_val", }] }; json = JSON.stringify(js); console.log(json); // {"p1":{"qq":"qq_val"},"p2":[{"qq":"qq_val"}]} Well, I just wanted to name the property, so…
-
3
votes4
answers135
viewsHow does object copying work?
var a = {a: 1, b: 2}; var b = a; b.a = 3; In the code above, b. a becomes worth 3, and a. a also becomes worth 3. var a = {a: 1, b: 2}; function b(objeto) { objeto.a = 3; } b(a); In the above code,…
-
3
votes1
answer54
viewsObjects in javascript
When we work with objects in javascript, and with the Angularjs framework, where we write the code of the objects? For example, I’m going to create an object that looks something like this: var…
-
3
votes1
answer434
viewsUndefined Object
I’m having problems with an object on Node.Js with Express.Js. He is reporting the following error. Error: Route.get() requires callback functions but got a [object Undefined] at…
-
3
votes4
answers8807
viewsHow to insert a property into a javascript object?
I have the following javascript object: data2 = { "desColigada": "Empresa fulano de tal", "codMatricula": "00555454", "dataImpressao": "23/05/2016" }; I need to know how to insert this array into…
-
3
votes2
answers154
viewsFind out if particular control is a button
I have the following code that serves to change the color of the buttons that are in a panel: private void mudaCorBotao(Button bt) { foreach(Control b in Panel_esq.Controls) { if (/*[O que devo…
-
3
votes3
answers14457
viewsTraversing Object array and accessing a value
Good afternoon guys, I’m having a difficulty, where I need to access an element of an array of OBJECTS, I’m not being able to access with foreach, or for. I need your help! The array of objects:…
-
3
votes1
answer66
viewsHow to find out in which generation of Garbage Telescope an object is allocated?
Considering my previous question on the generations of the CG, would like to understand if considering the "moment" through which an object is passing within its life cycle, brings some benefit or…