Javascript Articles

Page 448 of 534

How do you launch the JavaScript debugger in Google Chrome?

Abhinaya
Abhinaya
Updated on 23-Jun-2020 329 Views

To launch JavaScript debugger in Google Chrome, try any of the following ways,Press Ctrl + Shift + JGo to Settings and click More Tools. After that, click Developer Tools.For more, refer the official website of  Chrome Dev Tool,

Read More

How to define custom JavaScript exceptions?

V Jyothi
V Jyothi
Updated on 23-Jun-2020 218 Views

To learn how to define and implement custom JavaScript exceptions, you can try to run the following code −Example                                         Click the following to see the result:                          

Read More

What is the difference between custom and built-in functions in JavaScript?

Anvi Jain
Anvi Jain
Updated on 23-Jun-2020 756 Views

The custom functions in JavaScript are user-defined functions. JavaScript allows us to write our own functions. The following is the syntax −Syntax     Bult-in functions are functions already provided by JavaScript library, for example, the following are string functions −S. NoMethod & Description1charAt()Returns the character at the specified index.2charCodeAt()Returns a number indicating the Unicode value of the character at the given index.3concat()Combines the text of two strings and returns a new string.4indexOf()Returns the index within the calling String object of the first occurrence of the specified value, or -1 if not found.ExampleThe following is an example of a built-in ...

Read More

How to write a Regular Expression in JavaScript to remove spaces?

Anvi Jain
Anvi Jain
Updated on 23-Jun-2020 295 Views

To remove spaces in JavaScript, you can try to run the following regular expression. It removes the spaces from a string −Example Live Demo                    var str = "Welcome to Tutorialspoint";          document.write(str);                    //Removing Spaces          document.write(""+str.replace(/\s/g, ''));                       Output

Read More

How to write JavaScript Regular Expression for multiple matches?

Nikitha N
Nikitha N
Updated on 23-Jun-2020 253 Views

To find multiple matches, write a JavaScript regular expression. You can try to run the following code to implement regular expression for multiple matches −Example                    var url = 'https://www.example.com/new.html?ui=7&demo=one&demo=two&demo=three four',          a = document.createElement('a');          a.href = url;          var demoRegex = /(?:^|[&;])demo=([^&;]+)/g,          matches,          demo = [];          while (matches = demoRegex.exec(a.search)) {             demo.push(decodeURIComponent(matches[1]));          }          document.write(demo);                  

Read More

Write a Regular Expression to remove all special characters from a JavaScript String?

Nishtha Thakur
Nishtha Thakur
Updated on 23-Jun-2020 759 Views

To remove all special characters from a JavaScript string, you can try to run the following code −Example                    var str = "@!Welcome to our website$$";          document.write(str);                    // Removing Special Characters          document.write(""+str.replace(/[^\w\s]/gi, ''));                      

Read More

How to skip character in capture group in JavaScript Regexp?

Rishi Rathor
Rishi Rathor
Updated on 23-Jun-2020 981 Views

You cannot skip a character in a capture group. A match is always consecutive, even when it contains things like zero-width assertions.ExampleHowever, you can access the matched groups in a regular expression like the following code −                    var str = "Username akdg_amit";          var myReg = /(?:^|\s)akdg_(.*?)(?:\s|$)/g;                    var res = myReg.exec(str);          document.write(res[1]);                      

Read More

How to set current time to some other time in JavaScript?

Daniol Thomas
Daniol Thomas
Updated on 23-Jun-2020 606 Views

You cannot do this with JavaScript since it takes the system time which displays the current date with Date object. However, you can change the current date by changing the timezone as in the following code −Example Live Demo                    var date, offset, nd;          date = new Date();                  document.write("Current: "+date);          utc = date.getTime() + (date.getTimezoneOffset() * 60000);                  // Singapore is GMT+8          offset = 8;                  nd = new Date(utc + (3600000*offset));          document.write("Singapore Time: "+nd.toLocaleString());           Output

Read More

The Fibonacci sequence in Javascript

karthikeya Boyini
karthikeya Boyini
Updated on 22-Jun-2020 604 Views

Fibonacci numbers are the numbers such that every number in the series after the first two is the sum of the two preceding ones. The series starts with 1, 1. Example −1, 1, 2, 3, 5, 8, 13, 21, 34, ….We can write a program to generate nth as follows −functionfibNaive(n) {    if (n

Read More

How to define a JavaScript function using Function() Constructor?

Nikitha N
Nikitha N
Updated on 22-Jun-2020 235 Views

The Function() constructor expects any number of string arguments. The last argument is the body of the function - it can contain arbitrary JavaScript statements, separated from each other by semicolons.ExampleYou can try to run the following code to invoke a function with new Function Constructor −                    var func = new Function("x", "y", "return x*y;");          function multiplyFunction(){             var result;             result = func(15,35);             document.write ( result );          }                     Click the following button to call the function                          

Read More
Showing 4471–4480 of 5,338 articles
« Prev 1 446 447 448 449 450 534 Next »
Advertisements