Clear Usage of setInterval in JavaScript

George John
Updated on 23-Jun-2020 12:58:39

206 Views

The setInterval() method is used evaluate an expression at specified intervals. This function calls function after every duration milliseconds. This goes for unlimited times. Let’s see an example −It triggers alert(‘Hello’) after every 2000 milliseconds, not only once.setInterval(function() { alert('Hello');}, 2000);To clear the usage of setInterval(), use the window.clearInterval() and set the parameter as the ID, likewindow.setInterval();

Does Use of Anonymous Functions Affect Performance

Daniol Thomas
Updated on 23-Jun-2020 12:58:03

351 Views

The usage of anonymous functions affect performance is the sense, you need to create a new function object at each iteration. Anonymous functions are always loaded using a variable name. Anonymous, as the name suggests, allows creating a function without any names identifier. It can be used as an argument to other functions. Call them using a variable name −ExampleThis is how JavaScript anonymous functions can be used −var func = function() {    alert(‘This is anonymous'); } func();Here’s an example −//anonymous function var a = function() {    return 5; }

JavaScript Scroll Event for iPhone and iPad

Abhinanda Shri
Updated on 23-Jun-2020 12:57:22

369 Views

Yes, iOS capture onscroll events for a scroll. This is called one-finger events. What the user is tapping or touching decides whether an event is generated or not.Here is panning gesture,Image credit − AppleIt can also be touch and hold gesture,Image credit − Apple

Set Font to Small Capital Letters with JavaScript

Swarali Sree
Updated on 23-Jun-2020 12:56:31

211 Views

To set the font in small capital letters, use the fontVariant property.ExampleYou can try to run the following code to set the font to be displayed in small capital letters with JavaScript −Live Demo           Heading 1                This is Demo Text. This is Demo Text. This is Demo Text. This is Demo Text.          This is Demo Text. This is Demo Text. This is Demo Text. This is Demo Text.             Set Font Family and Font Variant                function display() {             document.getElementById("myID").style.fontFamily = "verdana,sans-serif";             document.getElementById("myID").style.fontVariant = "small-caps";          }          

Use the GetLongLength Method of Array Class in C#

George John
Updated on 23-Jun-2020 12:47:19

350 Views

The GetLongLength method in C# gets a 64-bit integer that represents the number of elements in the specified dimension of the Array.First, set the array.long[,] arr2= new long[15, 35];For a specified dimension of the array, set the index in the GetLongMethod() method like −long len2 = arr2.GetLongLength(0);Let us see the complete example.Example Live Demousing System; class Program {    static void Main() {       int[,] arr = new int[20, 30];       int len = arr.GetLength(0);       Console.WriteLine(len);       long[,] arr2= new long[15, 35];       long len2 = arr2.GetLongLength(0);       Console.WriteLine(len2);    } }Output20 15

Use getLowerBound Method of Array Class in C#

Samual Sam
Updated on 23-Jun-2020 12:46:53

476 Views

The GetLowerBound() method of array class in C# gets the lower bound of the specified dimension in the Array.Firstly, set the array and get the lower bound as shown below −arr.GetLowerBound(0).ToString()The following is an example stating the usage of GetLowerBound() method in C#.Example Live Demousing System; using System.Collections.Generic; using System.Linq; using System.Text; namespace lower {    class Program {       static void Main(string[] args) {          Array arr = Array.CreateInstance(typeof(String), 3);          arr.SetValue("Car", 0);          arr.SetValue("Truck", 1);          arr.SetValue("Motorbike", 2);          Console.WriteLine("Lower Bound {0}",arr.GetLowerBound(0).ToString());          Console.ReadLine();       }    } }OutputLower Bound 0

Sort a List in C#

Chandu yadav
Updated on 23-Jun-2020 12:46:20

241 Views

Set a list with some values. Here, we have a list of strings.var cars = new List() {"Mercedes", "Audi", "Jaguar" };To sort, simply use Sort() method.cars.Sort();The following is an example showing how to sort a list in C#.Example Live Demousing System; using System.Collections.Generic; public class Program {    public static void Main() {       var cars = new List() {"Mercedes", "Audi", "Jaguar" };       Console.WriteLine("Original Array =");       foreach (var name in cars) {          Console.WriteLine(name);       }       // sort       cars.Sort();       ... Read More

Use the GetType Method of Array Class in C#

karthikeya Boyini
Updated on 23-Jun-2020 12:45:29

3K+ Views

The GetType() method of array class in C# gets the Type of the current instance (Inherited from Object).To get the type.Type tp = value.GetType();In the below example, we are checking the int value using the type.if (tp.Equals(typeof(int))) Console.WriteLine("{0} is an integer data type.", value)The following is the usage of GetType() method in C#.Exampleusing System public class Program {    public static void Main() {       object[] values = { (int) 100, (long) 17111};       foreach (var value in values) {          Type tp = value.GetType();          if (tp.Equals(typeof(int)))     ... Read More

Sort One-Dimensional Array in Descending Order Using Non-Static Method

Arjun Thakur
Updated on 23-Jun-2020 12:44:58

229 Views

Set the unsorted list first.int[] list = {87, 45, 56, 22, 84, 65};Now use a nested for loop to sort the list that is passed to a function.for(int i=0; ilt; arr.Length; i++) {    for(int j=i+1; j

Use the GetValue Method of Array Class in C#

Ankith Reddy
Updated on 23-Jun-2020 12:42:50

3K+ Views

The GetValue() method of array class in C# gets the value at the specified position in the one-dimensional Array. The index is specified as a 32-bit integer.We have set the array values first using the Array.CreateInstance method.Array arr = Array.CreateInstance(typeof(String), 3, 6); arr.SetValue("One", 0, 0); arr.SetValue("Two", 0, 1); arr.SetValue("Three", 0, 2); arr.SetValue("Four", 0, 3); arr.SetValue("Five", 1, 4); arr.SetValue("Six", 1, 5); arr.SetValue("Seven", 1, 2); arr.SetValue("Eight", 1, 3);Then loop throught the array length. This will display all the values using the GetValue() method.for (int i = 0; i < a; i++) for (int j = 0; j < b; j++) Console.WriteLine( arr.GetValue(i, ... Read More

Advertisements