Questions tagged as 'javascript'

4
answers

Avoiding the error "Can not read property 'c' of undefined"

Considering the following code: var a = {}; if (a.b.c !== undefined) { console.log("definido!"); } else { console.log("indefinido!"); } Is there any way to check each property without having to test one by one? What I...
asked by 20.02.2017 / 19:20
4
answers

Difference between syntax for declaring a function

this response, I realized different forms of call a function using the jQuery. The first form would be this: $('#dois').on("click", testar); function testar() { console.log('Teste Dois'); } And the second one is this: $('#um').o...
asked by 17.11.2016 / 14:00
6
answers

Gradient color transition automatically smoothly

Hello, I have a div with the following css : background: linear-gradient(to right, #3e42e4, #e53472); And I would like colors to change through JavaScript. Similar to the top of this site: Pixelapse How can I do this?...
asked by 26.03.2015 / 19:48
7
answers

Mapping an array with possible subarrays as elements

I'm trying to create a function that maps an array to another newArray. If one of the array elements is a array , I want to map all of its subelements to newArray. Therefore: var array = [1,2,3,4,5, [1,3,2,4,1]] Should return   ...
asked by 18.06.2015 / 19:38
1
answer

How does ES7 async / await work?

ES7 allows you to use a new syntax to work with Promises known as async / await functions. How can I use these functions and how are they compared to functions that use Promises to process data sequences and in parallel?     
asked by 24.08.2016 / 00:41
2
answers

Synchronous requests

I need to make requests, however the first must be GET (getByName) and then execute the rest because they depend on it. It turns out that my code is sending an undefined as the requests depend on the contactsUri that is defined in this...
asked by 23.07.2015 / 18:15
4
answers

What would be a good way to apply events: onMouseOver and onMouseOut, for all img tag?

I need this function to be automated so that it applies to all images made on the HTML document without any exception Code function aumenta(obj) { obj.height = obj.height * 2; obj.width = obj.width * 2; } function diminui(...
asked by 08.02.2017 / 18:28
6
answers

Function that lists letters of the alphabet

How to convert the letters of the alphabet into an array of numbers according to its sequence? The array should start from # 1, not zero. So the letter A would be 1 , B would be 2 , C would be 3 , an...
asked by 15.03.2015 / 17:01
7
answers

Count elements on the screen

I would like to know if there is a possibility that I can count the elements on the screen, for example a function that lists the amount of <li> on my webpage. How could I do this? And how would function work?     
asked by 01.12.2015 / 14:54
4
answers

What is the difference between '==' and '===' operators in JavaScript? [duplicate]

I would like to know the difference between the two operators that would be: (1): == (2): === If possible, I would also like to understand the use of their opposite operators in this case: (3): != (4)...
asked by 30.01.2014 / 17:01