Questions tagged as 'javascript'

3
answers

regex return false?

console.log(rule); // rule = max18 // rule = max120 // rule = max6 var pattMax = new RegExp('^(max).(\d{1,3})'); pattMax.test(rule); //false? if(pattMax.test(rule)){ console.log('é max seguido de 1 á 3 digitos'); }     
asked by 14.08.2016 / 05:50
5
answers

Run script js when trying to close the window

I have a form that is a popup (overlapping div) <div class="bloco-newsletter" style="background-image: url(http://bhpump.izap.ws/plus/imggen/imageChangeColor/005873/bg-newsletter.png)"> <div class="newsletter-title">NEWSLETTER...
asked by 07.01.2016 / 21:47
3
answers

Remove a specific element from the javascript array

I need to remove an element from the array by index, for example: arr = [1,2,3,4,5,6] When removing the index element 3: arr = [1,2,3] It needs to remove everything after the index entered including the index. I tried to do this:...
asked by 13.01.2016 / 14:15
4
answers

Basic exercise JS: simple text search

I was trying to create a search in JS to find a given name in the body of a text. However, the search returns no value at all. The logic I used is: <script> var text = "Xxxxx, xxxx x xxxx x xxxx xxxxxx xxxxxxx. Lucas Menezes"; var myName...
asked by 17.01.2017 / 19:11
4
answers

Difference between && and ||

I would like to know the difference between: window.RM = window.RM || {}; E: window.RM = window.RM && {}; Maybe the examples are not correct, but I would like to know the difference between the && and || o...
asked by 04.02.2018 / 01:54
2
answers

How to create a toggle button on and toggle off?

I have seen that in some registers, they are using the toggle button a lot. Would anyone know how to do this?     
asked by 30.10.2016 / 18:40
4
answers

Separate text by space except within quotation marks

I'm trying to use a regex to separate space-separated texts, except for those within quotation marks, for example: Entrada: texto1 texto2 "texto3 texto4" texto5 Saida: Array("texto1", "texto2", "texto3 texto4", "texto5" ); Entrada: "texto0 t...
asked by 05.03.2018 / 18:50
3
answers

Function that returns function in Javascript

I started to study Javascript a short time ago and I came across a situation in a code (exercise) that I can not understand. function hi(a,b) { return a*b; } function hello(a,b) { return hi(a,b+1); } hello(3,3); What I understand fr...
asked by 15.03.2015 / 15:33
2
answers

Why can not I declare a variable with a number in front?

I'm curious to know why not being able to create variables with a number up front. I did some tests in JavaScript, ActionScript and C #. var 4teste:String = "teste"; //ActionScript, erro! var 4teste = "teste"; //Javascript, erro! String 4teste...
asked by 29.07.2015 / 15:43
3
answers

How to fix encoding problem in javascript?

I'm running the code below: alert('Não é possível realizar essa operação sem a seleção de uma banca.'); But it's popping up like this:     
asked by 27.02.2014 / 14:42