Questions tagged as 'javascript'

2
answers

Regular Expression for RG

I have a% w / o of% that defines the points by the maximum number of digits. Expression: function Rg(v){ v=v.replace(/\D/g,""); if(v.length == 9) v=v.replace(/(\d{2})(\d{3})(\d{3})(\d{1})$/,"$1.$2.$3-$4"); return v } expre...
asked by 25.06.2014 / 15:45
2
answers

String Builder (or How to improve the performance of massive replacements)

TL; DR: I know there is a class called StringBuilder, either at . NET and Java , which allows you to perform operations on a text without generating a new string for each method call. It would be very convenient to have something similar in...
asked by 16.05.2014 / 16:14
1
answer

Is it possible to work with Javascript Enumerators?

Commonly used in many languages Enumerators make life easier for developers when creating a "list" of constant values within an application. Within Javascript is it possible to use this structure?     
asked by 29.09.2017 / 19:35
2
answers

Number of repetitions per character

A friend gave me the following exercise:    Create a text-frequency function that returns an object containing the number of occurrences of each character in the text. I assumed that the argument passed is a string. According to my logic...
asked by 09.09.2014 / 17:57
3
answers

How to use a different logo if the default does not exist?

I wonder if there is a solution to the following problem, If there is a company logo, consider it and apply it to css, if there is no use of logo_default, then I could control versions and my users could customize the application without fear...
asked by 14.05.2015 / 15:08
2
answers

Merge two arrays into JavaScript

Imagine that I have two arrays: var array1 = ['abc', 'def', 'ghi']; var array2 = ['123', '456', '789']; I can use the .concat() function to join both arrays one after the other, for example: array1.concat(array2) // ['abc', 'def'...
asked by 27.01.2016 / 20:20
3
answers

What is the function of this 'e' that is passed as a parameter?

The example I'm going to show here is just to illustrate. I would like to really understand how this e works, which is usually passed as a parameter in several functions, that encounters in codes out there. $(".fotos").each(function...
asked by 25.09.2015 / 16:10
2
answers

A Absence of semicolons in CSS and Javascript can influence the operation of the code?

I always leave my css and javascript code minified but never noticed the generated output. Well, I noticed that the last rule of a selector (in css) and the last function (in javascript) always misses the semicolon. For example, a simple rule in...
asked by 28.10.2014 / 14:45
1
answer

How to return an object, calculating dates?

I'm calculating the difference between dates in a period. From today until previous days: hoje = new Date(); periodo = new Date().setDate(hoje.getDate() - 5); This way the output is as follows: Fri Sep 19 2014 17:05:11 GMT-0300 (Local Sta...
asked by 19.09.2014 / 22:09
2
answers

How to manage my message flow?

I have this JavaScript code that represents my connection to the WebSockets server, where it receives and sends messages to the server: var connection = new WebSocket('ws://127.0.0.1:2333'); connection.onopen = function () { // abriu a conexã...
asked by 24.07.2015 / 17:44