Questions tagged as 'javascript'

1
answer

What is the difference between the apply, call and bind methods when calling a function in Javascript?

Sometimes I use these methods but I do not know the difference between them (and I want to know what exactly that is for). function load( arg ) { console.log( this, arguments ); } load.apply('www', 'sss'); load.call('www', 'sss'); load.bi...
asked by 05.02.2014 / 15:55
3
answers

How to optimize this function for Fibonacci sequence?

On codility site there is an initial challenge for you to refactor this code: var yourself = { fibonacci : function(n) { if (n === 0) { return 0; } if (n === 1) { return 1; }...
asked by 13.01.2017 / 00:24
4
answers

Why are maps faster than arrays?

I have always read and heard that maps are much faster than arrays for searches. Until I decided to see how much I did a jsperf: link What I would like to understand is what mechanisms make mapping faster, and why. edit: In jsperf above,...
asked by 22.08.2014 / 21:41
3
answers

Doubt javascript function t (n, t, i, r)

I often see the source code of the pages and never understood that. function dt(n,t,i,r) What do these letters mean?     
asked by 05.01.2017 / 09:06
6
answers

How can I not allow numbers in a textbox?

Well folks, I'm trying to validate but have not yet succeeded. I want to do a function that does not let me enter numbers in a textbox . Here's an example of how I do it today. $(document).ready(function () { $('#nome_contacto')....
asked by 05.01.2016 / 00:36
2
answers

How to use the jsondiffpatch library?

I'm having second thoughts about manipulating the data with the jsondiffpatch library The original array : [ {"id":1004,"idproduto":3,"forma":"Alface","preco":1,"quantidade":1}, {"id":1000,"idproduto":3,"forma":"Bacon","preco":2,"qu...
asked by 05.03.2015 / 18:02
1
answer

Open WhatsApp when you click the icon

Someone knows how to do that by clicking on the WhatsApp icon on a site by smartphone , some function opens the application and already starts a conversation in the number defined in link from the website? Imagine an icon that says "WhatsA...
asked by 27.08.2015 / 02:31
3
answers

An image with display: none is loaded? Do you consume data?

I'm developing a responsive layout and would like to reduce the size of the images as per resolution. I've used display: none but I've seen in inspetor de elementos that it's loading. Is the data of the two images being consum...
asked by 21.08.2017 / 14:43
3
answers

Problem with click on input

I'm developing a hybrid application for mobile, using HTML5 and JS. I have the following problem: when I click, for example, in Nickname, it opens the Sex part. However, it is very strange behavior, it only happens when it is the first time the...
asked by 15.10.2015 / 14:47
2
answers

Reference loss in function call

Scenery: class ClassName { constructor(service, params) { this.service = service; this.params = params; this.save(params.id); } save(id) { const { service, onSuccess, onError } = this; re...
asked by 18.01.2017 / 14:08