Posts by Gabriel Katakura • 1,881 points
45 posts
-
3
votes2
answers153
viewsA: Next 0-Z Sequence Code with Javascript
From the understanding of the question, it seems that you are willing to work with a 36 basis, but the sequence example described in the question does not fall right into the 36 basis. The examples…
-
2
votes1
answer48
viewsA: C# is not finding/recognizing my List
You are trying to use the variable in the class scope, not within a method. So it won’t work. public class User { List<Frase> frases = new List<Frase>(); // isso é um atributo, não uma…
-
0
votes3
answers104
viewsA: How can I simplify access to the values of interest of a JSON in Javascript?
You can create a function that creates an alias for your object, always pointing to the path defined by the function. function get(source, path) { return path.split('.').reduce((currentValue,…
-
1
votes3
answers386
viewsA: Call a single time method within an Event Handler that is called several times?
If you want a more generic solution, using Closures together with the solution of jbueno, here you are: using System; public class Program { public static void Main() { EventHandler @event =…
-
3
votes2
answers24995
viewsA: Javascript function that completes the field with zeros on the left
You can create a function called leftPad, to fill in the values to the left of the value past, using the totalWidth to delimit to how much to fill and using the paddingChar to tell which character…
javascriptanswered Gabriel Katakura 1,881 -
4
votes2
answers307
viewsA: Calling function outside the scope in javascript
If you’re using class, are using ES6, then you can use Arrow Functions, which maintains the local scope from which they were declared, thus the this will work in your case. class Cliente {…
-
2
votes1
answer114
viewsA: Doubt using the Javascript Proxy API
The object Proxy has a high degree of flexibility, not only serves to observe changes made on top of an object, and precisely for this reason that when you write a behavior like set, get, has, you…
-
8
votes3
answers2766
viewsA: Count or Count()
The Count is a property manipulated by your list, which is incremented as you apply a Add in the list, that is, you have a direct access to the value when using it. The Count() is an extension…
-
2
votes2
answers369
viewsA: setTimeout does not work with For in javascript
The code is doing exactly what it was asked to do. You record a function on setTimeout and informs that from here 2000 milliseconds this function must be fired. Note that when you call the method…
javascriptanswered Gabriel Katakura 1,881 -
1
votes1
answer51
viewsA: Unread array with index set in input
In this scenario I do not see sense the use of the index on the property name, since there is another problem in this HTML. You’re doing the same id for more than one element on your page. The id,…
-
2
votes1
answer113
viewsA: Problems with Javascript callback
You are associating a new event with the element btnConfirmarAlteracao every time you call the function confirmarAlteracao. Or do you apply the unbind of the previously registered function, or…
-
4
votes5
answers5699
viewsA: How to get the current iteration index of a foreach?
The foreach does not possess knowledge of the current index to expose it in an elegant way, you have to control a variable manually even. This happens because the foreach is an independent structure…
-
1
votes2
answers236
viewsA: Avoiding conflicts between variables in Javascript
In order not to cause conflicts of superscript of globals variables (which I do not recommend using many, usually only use some to be access points), you can encapsulate the behavior of JS of their…
-
2
votes3
answers151
viewsA: How to create extension methods in the Entity Framework using Linq?
Yes, it has a way of doing this. Itself Where of IQueryable is actually a method of extension, in fact, most of the filters you have in IEnumerable and IQueryable are extension methods. That’s why…
-
5
votes2
answers443
viewsA: What happens when we assign a float value to a double variable?
No magic is happening here. It is only the way the information is being displayed that ends up confusing the user (developer). That’s the way the float is implemented when you write 3.1415f this is…
javaanswered Gabriel Katakura 1,881 -
3
votes5
answers1240
viewsA: How to split a string into specific Javascript sizes?
I always like to write the codes in ES5/ES6 versions, as well as their mandatory and functional versions, so to contribute here is a somewhat functional ES6 model: const splitStr = (str, size) =>…
-
2
votes1
answer44
viewsA: Convert treat null variable using the length property in Javascript
Yes, there is a simpler and readable way (my opinion) to return this, just use the unary operator of denial (!). In JS there are values that are considered falsy, that during an operation that…
javascriptanswered Gabriel Katakura 1,881 -
6
votes4
answers31463
viewsA: Onclick calling two functions at the same time Javascript
Tobymosque’s solution fits perfectly, but to give you another alternative, I’ll show you another way to solve the problem. This example is for if you want to add the events and no longer want to…
-
20
votes3
answers4688
viewsA: What is the difference between Function() {} and () => {}? Why doesn’t $http.get work?
As I noticed they didn’t explain the difference between () => {} and function() {}, then although there is an answer marked as correct, I will explain this difference. First of all it is very…
-
2
votes2
answers678
viewsA: Is it possible to definitely change the style of a CSS class using Javascript?
If the models are not created dynamically, they just change between themselves, you can do it that way: var cssAtual = 'red'; $("#mudarcss").click(function(){ cssAtual = 'blue';…
-
0
votes2
answers387
viewsA: Angular $timeout or Javascript timeout?
"The idea is basically the same", including in the documentation it is said that $timeout is a wrapper of window.setTimeout. The advantage of using $timeout is that it serves as a Promise, thus…
-
2
votes1
answer79
viewsA: Return value when $.getJSON is finished
$.getJSON returns a Promise, as soon as the operation of out.push is done asynchronously, that’s why it’s returning out empty. To resolve this, you will have to return a Promise in getThemes.…
-
2
votes2
answers570
viewsA: cmd.Commandtype = Commandtype.Text - Pq use?
It is not necessary to use in this case. In your example the CommandType makes no difference, because the default value of an Enum of CommandType is the value CommandType.Text. CommandType can be…
-
4
votes3
answers126
viewsA: Transition from Javascript Evolution to Cross Browser
From what I understand your question, you would like a list of features and which are the browsers (with version dictated) that that functionality is implemented. There is a site that does just…
-
1
votes2
answers390
viewsA: Function returns a string instead of a prefix
To turn a value into a Promise that there was success of response, just you encapsulate the value with Promise.resolve. var dealershipsCache = []; function getDealerships(region) { if ( region in…
-
3
votes3
answers823
viewsA: Method that returns parent class to daughter class
Just use Generics for this (short answer, I’m out of time, sorry): public TPessoa Teste<TPessoa>(TPessoa pessoa) where TPessoa : Pessoa { return pessoa; }…
-
8
votes1
answer112
viewsA: Is it safe to use the new syntactic sugar for Javascript callbacks?
It is not safe. Ecmascript 6 is not receiving 100% support of Features yet in browsers (even modern ones), and even though the latest version of the browser supports these Eatures you will limit the…
-
8
votes2
answers2357
viewsA: Why is it necessary to use bind when working with ES6 and Reactjs?
this dynamic The bind solves a problem caused by the context of JavaScript, It provides a way to ensure that even decontaminating a function of an object its behavior remains the same, thus ensuring…
-
2
votes1
answer89
viewsA: Consultation on the Activerecord
Responsible.where(id: 1).joins(students: [ school: [ :works, :work_zeis ] ]).first
-
0
votes2
answers70
viewsA: $. GET Jquery Dùvida
I strongly recommend that you do not work synchronously with AJAX. Synchronous requests are obsolete and this makes a lot of sense, in one language Single-Thread, competing with renderings of HTML…
-
0
votes1
answer55
viewsA: Ng-reapeat selects input from all Forms change together
According to the link that was past, all the ICMS were operating on top of the same object, the Selected. To solve the problem, simply remove the Selected (which is unnecessary in this case), and…
-
1
votes1
answer845
viewsA: Run Javascript code by clicking link within DIV
You have to register an event to be monitoring the action of click in his div. Note that here is being monitored all the elements that have the classname equal to fb-post, where classname…
-
7
votes1
answer92
viewsA: What is the equivalent of the PHP array_map in C#?
using System.Linq; var arr = Enumerable.Range(1, 3).Select(x => x * 2).ToArray(); Here is the implementation of Enumerable.Range: public static IEnumerable<int> Range(int start, int count)…
c#answered Gabriel Katakura 1,881 -
3
votes2
answers3375
viewsA: In Nodejs, the global variable in my app.js file is undefined in another file
Clearly your code problem is with asynchrony. Promises can solve your problem: function readFileCredentials(file) { return new Promise(function(resolve, reject) {…
-
6
votes1
answer3354
viewsA: How to validate a digitized line of billets in the format 00000.00000 00000.000000 00000.000000 0 00000000000000?
If you want to validate only the format, here is a solution with Regular Expression: using System; using System.Globalization; using System.Text.RegularExpressions; public class Program { public…
-
11
votes6
answers1578
viewsA: Is it good practice to use constructors (or magic methods) in interfaces?
First, I would like to inform you that what I am about to pass on to you is only my opinion, I have no great references to point out here. Second, I will write the examples in C#, I know PHP, but I…
-
2
votes10
answers1739
viewsA: How to count the zeroes to the right of a number?
Javascript version (ES6) with Regexp: const contarZeros = (numero) => /0*$/.exec(numero)[0].length;
-
2
votes1
answer416
viewsA: Async Method with Await in his Return
In that case it really doesn’t make sense the use of async/await. Asymchronism is one way to inform a Thread that when a transaction occurs await that one Thread no need to wait for the result of…
-
0
votes1
answer941
viewsA: C# List<> - Insert into database
From what I see, the problem here is that three lists are being created to operate, instead of using only one, facilitating abstraction of the idea of Row. First you would have to have a class that…
-
3
votes2
answers79
viewsA: Problems making ajax call with checkbox
The id attribute serves (as its own name says) as a unique identification for the page, it should not have two elements in the same frame with the same id. Instead of $("#Selectdias") prefer to use…
-
0
votes1
answer101
viewsA: Extract data in Jquery
The ajax operation is done asynchronously, i.e., it is only concatenating that text into the variable when the request is returned. Move the print variable and the rest of the code into the Success…
-
1
votes1
answer98
viewsA: Manipulating multiple-level object parameters in Javascript
function set(object, param, value) { var levels = param.split('.'); var lastLevel = levels.pop(); get(object, levels.join('.'))[lastLevel] = value; }
javascriptanswered Gabriel Katakura 1,881 -
1
votes5
answers4348
viewsA: How to access the value of an array through the key?
arr.find(function(element) { return element.hasOwnProperty('Camilla') })['Camilla'];
-
1
votes2
answers1756
viewsA: C# Challenge Variable value exchange
Following exactly the same idea as jbueno, but using the tricks of weak typing languages, where in C# these advantages can be achieved with Dynamic. dynamic a = "Teste"; string b = "Overflow"; a =…
-
7
votes1
answer77
viewsA: PHP being commented within JS
This will not work. PHP is processed by the Server, while Javascript code in this case is processed by the Client (Browser). You can create a looping in PHP to write Javascript code, but it is not…